mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
adapt on new response of GMS.verifyAuthToken - only the token will be
returned not a complete URI
This commit is contained in:
parent
c5c6592964
commit
12cae42d0e
@ -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)
|
||||
|
||||
10
backend/src/graphql/model/GmsUserAuthenticationResult.ts
Normal file
10
backend/src/graphql/model/GmsUserAuthenticationResult.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Field, ObjectType } from 'type-graphql'
|
||||
|
||||
@ObjectType()
|
||||
export class GmsUserAuthenticationResult {
|
||||
@Field(() => String)
|
||||
url: string
|
||||
|
||||
@Field(() => String)
|
||||
token: string
|
||||
}
|
||||
@ -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<string> {
|
||||
@Query(() => GmsUserAuthenticationResult)
|
||||
async authenticateGmsUserSearch(@Ctx() context: Context): Promise<GmsUserAuthenticationResult> {
|
||||
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])
|
||||
|
||||
@ -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<string> {
|
||||
const gmsPlaygroundUri = await verifyAuthToken(dbUser.communityUuid, token)
|
||||
|
||||
return gmsPlaygroundUri
|
||||
export async function authenticateGmsUserPlayground(
|
||||
token: string,
|
||||
dbUser: DbUser,
|
||||
): Promise<GmsUserAuthenticationResult> {
|
||||
const result = new GmsUserAuthenticationResult()
|
||||
result.url = CONFIG.GMS_URL.concat('/playground')
|
||||
result.token = await verifyAuthToken(dbUser.communityUuid, token)
|
||||
console.log('GmsUserAuthenticationResult:', result)
|
||||
return result
|
||||
}
|
||||
|
||||
@ -18,7 +18,8 @@ export const verifyLogin = gql`
|
||||
export const authenticateGmsUserSearch = gql`
|
||||
query {
|
||||
authenticateGmsUserSearch {
|
||||
gmsPlaygroundUri
|
||||
url
|
||||
token
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user