mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
next try for menu-entry userplayground
This commit is contained in:
parent
7781a088d0
commit
4f724543e9
@ -202,7 +202,7 @@ export async function verifyAuthToken(
|
||||
}
|
||||
try {
|
||||
const result = await axios.get(baseUrl.concat(service), config)
|
||||
logger.debug('GET-Response of verify-auth-token:', result)
|
||||
console.log('GET-Response of verify-auth-token:', result)
|
||||
if (result.status !== 200) {
|
||||
throw new LogError(
|
||||
'HTTP Status Error in verify-auth-token:',
|
||||
@ -210,11 +210,11 @@ export async function verifyAuthToken(
|
||||
result.statusText,
|
||||
)
|
||||
}
|
||||
logger.debug('responseData:', result.data.responseData)
|
||||
console.log('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
|
||||
console.log('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
|
||||
}
|
||||
@ -79,6 +79,7 @@ import { Location2Point } from './util/Location2Point'
|
||||
import { setUserRole, deleteUserRole } from './util/modifyUserRole'
|
||||
import { sendUserToGms } from './util/sendUserToGms'
|
||||
import { validateAlias } from './util/validateAlias'
|
||||
import { GmsUserAuthenticationResult } from '../model/GmsUserAuthenticationResult'
|
||||
|
||||
const LANGUAGES = ['de', 'en', 'es', 'fr', 'nl']
|
||||
const DEFAULT_LANGUAGE = 'de'
|
||||
@ -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)
|
||||
console.log('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
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@ -28,13 +28,13 @@
|
||||
<b-icon icon="layers" aria-hidden="true"></b-icon>
|
||||
<span class="ml-2">{{ $t('GDT') }}</span>
|
||||
</b-nav-item>
|
||||
<b-nav-item to="/information" active-class="activeRoute">
|
||||
<b-nav-item to="/information" class="mb-3" active-class="activeRoute">
|
||||
<b-img src="/img/svg/info.svg" height="20" class="svg-icon" />
|
||||
<span class="ml-2">{{ $t('navigation.info') }}</span>
|
||||
</b-nav-item>
|
||||
<b-nav-item to="/usersearch" active-class="activeRoute">
|
||||
<b-img src="/img/svg/loupe.png" height="20" class="svg-icon" />
|
||||
<span class="ml-2">{{ $t('usersearch') }}</span>
|
||||
<span class="ml-2">{{ $t('navigation.usersearch') }}</span>
|
||||
</b-nav-item>
|
||||
</b-nav>
|
||||
<hr class="m-3" />
|
||||
|
||||
@ -22,12 +22,12 @@ export const verifyLogin = gql`
|
||||
export const authenticateGmsUserSearch = gql`
|
||||
query {
|
||||
authenticateGmsUserSearch {
|
||||
gmsPlaygroundUri
|
||||
url
|
||||
token
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||
|
||||
@ -268,7 +268,8 @@
|
||||
"send": "Senden",
|
||||
"settings": "Einstellung",
|
||||
"support": "Support",
|
||||
"transactions": "Transaktionen"
|
||||
"transactions": "Transaktionen",
|
||||
"usersearch": "Nutzersuche"
|
||||
},
|
||||
"openHours": "Offene Stunden",
|
||||
"pageTitle": {
|
||||
|
||||
@ -268,7 +268,8 @@
|
||||
"send": "Send",
|
||||
"settings": "Settings",
|
||||
"support": "Support",
|
||||
"transactions": "Transactions"
|
||||
"transactions": "Transactions",
|
||||
"usersearch": "User Search"
|
||||
},
|
||||
"openHours": "Open Hours",
|
||||
"pageTitle": {
|
||||
|
||||
@ -250,7 +250,8 @@
|
||||
"send": "Envoyer",
|
||||
"settings": "Configuration",
|
||||
"support": "Aide",
|
||||
"transactions": "Transactions"
|
||||
"transactions": "Transactions",
|
||||
"usersearch": "Recherche d'Utilisateur"
|
||||
},
|
||||
"openHours": "Heures ouverte",
|
||||
"pageTitle": {
|
||||
|
||||
@ -10,18 +10,10 @@ export default {
|
||||
name: 'GMS User Playground',
|
||||
data() {
|
||||
return {
|
||||
gmsPlaygroundUri: '',
|
||||
gmsPlaygroundUrl: 'unknown',
|
||||
gmsAuthToken: '',
|
||||
}
|
||||
},
|
||||
/*
|
||||
async mounted() {
|
||||
let query = `{
|
||||
authenticateGmsUserSearch() {
|
||||
gmsPlaygroundUri
|
||||
}
|
||||
}`;
|
||||
},
|
||||
*/
|
||||
methods: {
|
||||
authenticateGmsUserPlayground() {
|
||||
this.$apollo
|
||||
@ -29,13 +21,23 @@ export default {
|
||||
query: authenticateGmsUserSearch,
|
||||
})
|
||||
.then((result) => {
|
||||
this.gmsPlaygroundUri = result.data.authenticateGmsUserSearch.gmsPlaygroundUri
|
||||
this.gmsPlaygroundUrl = result.data.url,
|
||||
this.gmsAuthToken = result.data.token
|
||||
})
|
||||
.catch(() => {
|
||||
this.toastError('listContributionLinks has no result, use default data')
|
||||
})
|
||||
},
|
||||
},
|
||||
/*
|
||||
openGmsUserPlayground: function () {
|
||||
// window.open(this.gmsPlaygroundUrl + '?' + this.gmsAuthToken, '_blank')
|
||||
let uri = this.gmsPlaygroundUrl + '?' + this.gmsAuthToken
|
||||
let route = this.$router.resolve({path: uri});
|
||||
// let route = this.$router.resolve('/link/to/page'); // This also works.
|
||||
window.open(route.href, '_blank');
|
||||
},
|
||||
*/
|
||||
created() {
|
||||
this.authenticateGmsUserPlayground()
|
||||
},
|
||||
|
||||
@ -87,11 +87,6 @@ const routes = [
|
||||
requiresAuth: true,
|
||||
pageTitle: 'user search',
|
||||
},
|
||||
/*
|
||||
redirect: (to) => {
|
||||
return { path: '/login' }
|
||||
},
|
||||
*/
|
||||
},
|
||||
// {
|
||||
// path: '/storys',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user