diff --git a/backend/src/apis/gms/GmsClient.ts b/backend/src/apis/gms/GmsClient.ts index 46cf38e54..32a3802ff 100644 --- a/backend/src/apis/gms/GmsClient.ts +++ b/backend/src/apis/gms/GmsClient.ts @@ -212,9 +212,9 @@ export async function verifyAuthToken( } logger.debug('responseData:', result.data.responseData) // eslint-disable-next-line @typescript-eslint/no-unsafe-call - const playgroundUri: string = JSON.parse(result.data.responseData.data) - logger.debug('verifyAuthToken=', playgroundUri) - return playgroundUri + const token: string = result.data.responseData.token + logger.debug('verifyAuthToken=', token) + return token } catch (error: any) { logger.error('Error in verifyAuthToken:', error) throw new LogError(error.message) diff --git a/backend/src/graphql/model/GmsUserAuthenticationResult.ts b/backend/src/graphql/model/GmsUserAuthenticationResult.ts new file mode 100644 index 000000000..b1fb2c246 --- /dev/null +++ b/backend/src/graphql/model/GmsUserAuthenticationResult.ts @@ -0,0 +1,10 @@ +import { Field, ObjectType } from 'type-graphql' + +@ObjectType() +export class GmsUserAuthenticationResult { + @Field(() => String) + url: string + + @Field(() => String) + token: string +} diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 44ae3e722..7c11776df 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -25,6 +25,7 @@ import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' import { UserContactType } from '@enum/UserContactType' import { SearchAdminUsersResult } from '@model/AdminUser' // import { Location } from '@model/Location' +import { GmsUserAuthenticationResult } from '@model/GmsUserAuthenticationResult' import { User } from '@model/User' import { UserAdmin, SearchUsersResult } from '@model/UserAdmin' @@ -676,18 +677,18 @@ export class UserResolver { } @Authorized([RIGHTS.GMS_USER_PLAYGROUND]) - @Query(() => String) - async authenticateGmsUserSearch(@Ctx() context: Context): Promise { + @Query(() => GmsUserAuthenticationResult) + async authenticateGmsUserSearch(@Ctx() context: Context): Promise { logger.info(`authUserForGmsUserSearch()...`) const dbUser = getUser(context) - let gmsPlaygroundUri: string + let result: GmsUserAuthenticationResult if (context.token) { - gmsPlaygroundUri = await authenticateGmsUserPlayground(context.token, dbUser) - logger.debug('authUserForGmsUserSearch=', gmsPlaygroundUri) + result = await authenticateGmsUserPlayground(context.token, dbUser) + logger.info('authUserForGmsUserSearch=', result) } else { throw new LogError('authUserForGmsUserSearch without token') } - return gmsPlaygroundUri + return result } @Authorized([RIGHTS.SEARCH_ADMIN_USERS]) diff --git a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts index 5ad51ee42..53c752b5d 100644 --- a/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts +++ b/backend/src/graphql/resolver/util/authenticateGmsUserPlayground.ts @@ -1,9 +1,16 @@ import { User as DbUser } from '@entity/User' import { verifyAuthToken } from '@/apis/gms/GmsClient' +import { CONFIG } from '@/config' +import { GmsUserAuthenticationResult } from '@/graphql/model/GmsUserAuthenticationResult' -export async function authenticateGmsUserPlayground(token: string, dbUser: DbUser): Promise { - const gmsPlaygroundUri = await verifyAuthToken(dbUser.communityUuid, token) - - return gmsPlaygroundUri +export async function authenticateGmsUserPlayground( + token: string, + dbUser: DbUser, +): Promise { + const result = new GmsUserAuthenticationResult() + result.url = CONFIG.GMS_URL.concat('/playground') + result.token = await verifyAuthToken(dbUser.communityUuid, token) + console.log('GmsUserAuthenticationResult:', result) + return result } diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 904b097fc..b097a2710 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -18,7 +18,8 @@ export const verifyLogin = gql` export const authenticateGmsUserSearch = gql` query { authenticateGmsUserSearch { - gmsPlaygroundUri + url + token } } `