From 0c3b0f7a531260e2c3df9e07441c9632c160fdf6 Mon Sep 17 00:00:00 2001 From: clauspeterhuebner Date: Mon, 25 Nov 2024 22:40:52 +0100 Subject: [PATCH] correct parameters for authenticateGmsUserPlayground --- backend/src/graphql/resolver/UserResolver.ts | 14 +++++++++----- .../resolver/util/authenticateGmsUserPlayground.ts | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index acaeac60f..79217328f 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -728,14 +728,18 @@ export class UserResolver { @Authorized([RIGHTS.GMS_USER_PLAYGROUND]) @Query(() => GmsUserAuthenticationResult) async authenticateGmsUserSearch(@Ctx() context: Context): Promise { - logger.info(`authUserForGmsUserSearch()...`) + logger.info(`authenticateGmsUserSearch()...`) const dbUser = getUser(context) - let result: GmsUserAuthenticationResult + let result = new GmsUserAuthenticationResult() if (context.token) { - result = await authenticateGmsUserPlayground(context.token, dbUser) - logger.info('authUserForGmsUserSearch=', result) + const homeCom = await getHomeCommunity() + if (!homeCom.gmsApiKey) { + throw new LogError('authenticateGmsUserSearch missing HomeCommunity GmsApiKey') + } + result = await authenticateGmsUserPlayground(homeCom.gmsApiKey, context.token, dbUser) + logger.info('authenticateGmsUserSearch=', result) } else { - throw new LogError('authUserForGmsUserSearch without token') + throw new LogError('authenticateGmsUserSearch missing valid user login-token') } return result } diff --git a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts index ef3c199c9..11e92ce53 100644 --- a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts +++ b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts @@ -7,13 +7,14 @@ import { backendLogger as logger } from '@/server/logger' import { ensureUrlEndsWithSlash } from '@/util/utilities' export async function authenticateGmsUserPlayground( + apiKey: string, token: string, dbUser: DbUser, ): Promise { const result = new GmsUserAuthenticationResult() const dashboardUrl = ensureUrlEndsWithSlash(CONFIG.GMS_DASHBOARD_URL) - result.url = dashboardUrl.concat('playground') + result.url = dashboardUrl.concat('usersearch-playground') result.token = await verifyAuthToken(dbUser.communityUuid, token) logger.info('GmsUserAuthenticationResult:', result) return result