correct parameters for authenticateGmsUserPlayground

This commit is contained in:
clauspeterhuebner 2024-11-25 22:40:52 +01:00
parent ad3ebefa3a
commit 0c3b0f7a53
2 changed files with 11 additions and 6 deletions

View File

@ -728,14 +728,18 @@ export class UserResolver {
@Authorized([RIGHTS.GMS_USER_PLAYGROUND])
@Query(() => GmsUserAuthenticationResult)
async authenticateGmsUserSearch(@Ctx() context: Context): Promise<GmsUserAuthenticationResult> {
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
}

View File

@ -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<GmsUserAuthenticationResult> {
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