next try for menu-entry userplayground

This commit is contained in:
Claus-Peter Huebner 2024-03-27 02:57:51 +01:00
parent 7781a088d0
commit 4f724543e9
12 changed files with 58 additions and 39 deletions

View File

@ -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)

View File

@ -0,0 +1,10 @@
import { Field, ObjectType } from 'type-graphql'
@ObjectType()
export class GmsUserAuthenticationResult {
@Field(() => String)
url: string
@Field(() => String)
token: string
}

View File

@ -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])

View File

@ -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
}

View File

@ -18,7 +18,8 @@ export const verifyLogin = gql`
export const authenticateGmsUserSearch = gql`
query {
authenticateGmsUserSearch {
gmsPlaygroundUri
url
token
}
}
`

View File

@ -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" />

View File

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

View File

@ -268,7 +268,8 @@
"send": "Senden",
"settings": "Einstellung",
"support": "Support",
"transactions": "Transaktionen"
"transactions": "Transaktionen",
"usersearch": "Nutzersuche"
},
"openHours": "Offene Stunden",
"pageTitle": {

View File

@ -268,7 +268,8 @@
"send": "Send",
"settings": "Settings",
"support": "Support",
"transactions": "Transactions"
"transactions": "Transactions",
"usersearch": "User Search"
},
"openHours": "Open Hours",
"pageTitle": {

View File

@ -250,7 +250,8 @@
"send": "Envoyer",
"settings": "Configuration",
"support": "Aide",
"transactions": "Transactions"
"transactions": "Transactions",
"usersearch": "Recherche d'Utilisateur"
},
"openHours": "Heures ouverte",
"pageTitle": {

View File

@ -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()
},

View File

@ -87,11 +87,6 @@ const routes = [
requiresAuth: true,
pageTitle: 'user search',
},
/*
redirect: (to) => {
return { path: '/login' }
},
*/
},
// {
// path: '/storys',