From ba4484e9fdc742622c6cf0827f457b2ac4861075 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Thu, 4 Apr 2024 22:03:18 +0200 Subject: [PATCH] adapt result of authenticated gms playground for new frontend page --- backend/src/apis/gms/GmsClient.ts | 12 +++++++++--- backend/src/config/index.ts | 5 +++-- .../resolver/util/authenticateGmsUserPlayground.ts | 6 +++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index 32a3802ff..6708c5fc2 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -118,7 +118,9 @@ export async function userByUuid(uuid: string): Promise { 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 { 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 { - 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: { diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index dd35d180e..56792316f 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -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', } diff --git a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts index cad98c683..3f1677244 100644 --- a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts +++ b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts @@ -10,7 +10,11 @@ export async function authenticateGmsUserPlayground( dbUser: DbUser, ): Promise { 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