mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
further tests adapted
This commit is contained in:
parent
ddee5707f5
commit
9830afb91c
@ -35,14 +35,20 @@ export const isAuthorized: AuthChecker<Context> = async ({ context }, rights) =>
|
||||
where: { gradidoID: decoded.gradidoID },
|
||||
relations: ['emailContact', 'userRoles'],
|
||||
})
|
||||
console.log('isAuthorized user=', user)
|
||||
// console.log('isAuthorized user=', user)
|
||||
context.user = user
|
||||
context.role = user.userRoles
|
||||
? user.userRoles[0].role === ROLE_NAMES.ROLE_NAME_ADMIN
|
||||
? ROLE_ADMIN
|
||||
: ROLE_MODERATOR
|
||||
: ROLE_USER
|
||||
if (user.userRoles && user.userRoles.length > 0) {
|
||||
if (user.userRoles[0].role === ROLE_NAMES.ROLE_NAME_ADMIN) {
|
||||
context.role = ROLE_ADMIN
|
||||
} else if (user.userRoles[0].role === ROLE_NAMES.ROLE_NAME_MODERATOR) {
|
||||
context.role = ROLE_MODERATOR
|
||||
}
|
||||
} else {
|
||||
context.role = ROLE_USER
|
||||
}
|
||||
// console.log('context.role=', context.role)
|
||||
} catch {
|
||||
// console.log('401 Unauthorized for decoded', decoded)
|
||||
// in case the database query fails (user deleted)
|
||||
throw new LogError('401 Unauthorized')
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ export const contributionLinkFactory = async (
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
console.log('contributionlinkfactory user=', user)
|
||||
const variables = {
|
||||
amount: contributionLink.amount,
|
||||
memo: contributionLink.memo,
|
||||
|
||||
@ -16,6 +16,7 @@ export class UserRepository extends Repository<DbUser> {
|
||||
.select(select)
|
||||
.withDeleted()
|
||||
.leftJoinAndSelect('user.emailContact', 'emailContact')
|
||||
.leftJoinAndSelect('user.userRoles', 'userRoles')
|
||||
.where(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user