import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
import { webMethod, Permissions } from "wix-web-module"; import { currentMember } from "wix-members-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; import { fetch } from "wix-fetch"; const getSecretValue = elevate(secrets.getSecretValue); const SESSION_ENDPOINT = "https://94-177-199-218.sslip.io/staff-portal/api/session/exchange"; const PILOT_OWNER_MEMBER_IDS = new Set(["d755a7a5-b735-4f83-821b-cda4dac76589"]); const OPERATOR_KEY_BY_LOGIN_EMAIL = new Map([ ["ericpaterniani@gmail.com", "eric"], ["duepiume@hotmail.it", "francesca"], ]); export const getDt8PortalSession = webMethod(Permissions.SiteMember, async () => { const [member, roles, secretResponse] = await Promise.all([ currentMember.getMember(), currentMember.getRoles(), getSecretValue("DT8_PORTAL_BRIDGE_SECRET"), ]); const roleNames = roles.map((role) => role.name); const loginEmail = typeof member.loginEmail === "string" ? member.loginEmail.trim().toLowerCase() : ""; const operatorKey = OPERATOR_KEY_BY_LOGIN_EMAIL.get(loginEmail) || null; const isAuthorizedRole = roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") || roleNames.includes("Admin"); const isPilotOwner = PILOT_OWNER_MEMBER_IDS.has(member._id); if (!isAuthorizedRole && !isPilotOwner) throw new Error("Ruolo Personale DT8 richiesto."); const portalRoles = isPilotOwner && !isAuthorizedRole ? ["Admin"] : roleNames.includes("Admin") ? ["Admin"] : roleNames.includes("Personale DT8") || roleNames.includes("Operatore DT8") ? ["Personale DT8"] : roleNames; const bridgeSecretValue = typeof secretResponse === "string" ? secretResponse : secretResponse?.value; const bridgeSecret = typeof bridgeSecretValue === "string" ? bridgeSecretValue.trim() : ""; if (!bridgeSecret) throw new Error("Secret DT8_PORTAL_BRIDGE_SECRET non configurato."); const response = await fetch(SESSION_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", "x-dt8-wix-secret": bridgeSecret }, body: JSON.stringify({ memberId: member._id, roles: portalRoles, operatorKey }), }); if (!response.ok) throw new Error("Sessione Operatori DT8 non disponibile."); const session = await response.json(); return { token: session.token, expiresIn: session.expiresIn }; });
A NEW ART IN ROLE PLAYING GAME
enhance your game sessions






