adapt result of authenticated gms playground for new frontend page

This commit is contained in:
Claus-Peter Huebner 2024-04-04 22:03:18 +02:00
parent 48516e7f46
commit ba4484e9fd
3 changed files with 17 additions and 6 deletions

View File

@ -118,7 +118,9 @@ export async function userByUuid(uuid: string): Promise<GmsUser[] | string | und
export async function createGmsUser(apiKey: string, user: GmsUser): Promise<boolean> {
if (CONFIG.GMS_ACTIVE) {
const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/')
const baseUrl = CONFIG.GMS_API_URL.endsWith('/')
? CONFIG.GMS_API_URL
: CONFIG.GMS_API_URL.concat('/')
const service = 'community-user'
const config = {
headers: {
@ -152,7 +154,9 @@ export async function createGmsUser(apiKey: string, user: GmsUser): Promise<bool
export async function updateGmsUser(apiKey: string, user: GmsUser): Promise<boolean> {
if (CONFIG.GMS_ACTIVE) {
const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/')
const baseUrl = CONFIG.GMS_API_URL.endsWith('/')
? CONFIG.GMS_API_URL
: CONFIG.GMS_API_URL.concat('/')
const service = 'community-user'
const config = {
headers: {
@ -189,7 +193,9 @@ export async function verifyAuthToken(
communityUuid: string,
token: string,
): Promise<string> {
const baseUrl = CONFIG.GMS_URL.endsWith('/') ? CONFIG.GMS_URL : CONFIG.GMS_URL.concat('/')
const baseUrl = CONFIG.GMS_API_URL.endsWith('/')
? CONFIG.GMS_API_URL
: CONFIG.GMS_API_URL.concat('/')
const service = 'verify-auth-token?token='.concat(token).concat('&uuid=').concat(communityUuid)
const config = {
headers: {

View File

@ -19,7 +19,7 @@ const constants = {
LOG_LEVEL: process.env.LOG_LEVEL ?? 'info',
CONFIG_VERSION: {
DEFAULT: 'DEFAULT',
EXPECTED: 'v22.2024-03-14',
EXPECTED: 'v23.2024-04-04',
CURRENT: '',
},
}
@ -145,7 +145,8 @@ const gms = {
GMS_ACTIVE: process.env.GMS_ACTIVE === 'true' || false,
GMS_CREATE_USER_THROW_ERRORS: process.env.GMS_CREATE_USER_THROW_ERRORS === 'true' || false,
// koordinates of Illuminz-instance of GMS
GMS_URL: process.env.GMS_HOST ?? 'http://localhost:4044/',
GMS_API_URL: process.env.GMS_API_URL ?? 'http://localhost:4044/',
GMS_DASHBOARD_URL: process.env.GMS_DASHBOARD_URL ?? 'http://localhost:8080/',
// used as secret postfix attached at the gms community-auth-url endpoint ('/hook/gms/' + 'secret')
GMS_WEBHOOK_SECRET: process.env.GMS_WEBHOOK_SECRET ?? 'secret',
}

View File

@ -10,7 +10,11 @@ export async function authenticateGmsUserPlayground(
dbUser: DbUser,
): Promise<GmsUserAuthenticationResult> {
const result = new GmsUserAuthenticationResult()
result.url = CONFIG.GMS_URL.concat('/playground')
const dashboardUrl = CONFIG.GMS_DASHBOARD_URL.endsWith('/')
? CONFIG.GMS_DASHBOARD_URL
: CONFIG.GMS_DASHBOARD_URL.concat('/')
result.url = dashboardUrl.concat('playground')
result.token = await verifyAuthToken(dbUser.communityUuid, token)
logger.info('GmsUserAuthenticationResult:', result)
return result