mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
use isAdmin on user to determine if user is admin
This commit is contained in:
parent
5c6aa5d4ce
commit
64859a71f4
@ -14,8 +14,8 @@ export class User {
|
||||
this.emailChecked = user.emailChecked
|
||||
this.language = user.language
|
||||
this.publisherId = user.publisherId
|
||||
this.isAdmin = user.isAdmin
|
||||
// TODO
|
||||
this.isAdmin = null
|
||||
this.coinanimation = null
|
||||
this.klickTipp = null
|
||||
this.hasElopage = null
|
||||
@ -58,11 +58,11 @@ export class User {
|
||||
|
||||
// `passphrase` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
|
||||
@Field(() => Boolean)
|
||||
isAdmin: boolean
|
||||
|
||||
// TODO this is a bit inconsistent with what we query from the database
|
||||
// therefore all those fields are now nullable with default value null
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
isAdmin: boolean | null
|
||||
|
||||
@Field(() => Boolean, { nullable: true })
|
||||
coinanimation: boolean | null
|
||||
|
||||
|
||||
@ -19,9 +19,7 @@ import { sendResetPasswordEmail as sendResetPasswordEmailMailer } from '@/mailer
|
||||
import { sendAccountActivationEmail } from '@/mailer/sendAccountActivationEmail'
|
||||
import { klicktippSignIn } from '@/apis/KlicktippController'
|
||||
import { RIGHTS } from '@/auth/RIGHTS'
|
||||
import { ROLE_ADMIN } from '@/auth/ROLES'
|
||||
import { hasElopageBuys } from '@/util/hasElopageBuys'
|
||||
import { ServerUser } from '@entity/ServerUser'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const sodium = require('sodium-native')
|
||||
@ -207,7 +205,6 @@ export class UserResolver {
|
||||
})
|
||||
user.coinanimation = coinanimation
|
||||
|
||||
user.isAdmin = context.role === ROLE_ADMIN
|
||||
return user
|
||||
}
|
||||
|
||||
@ -243,9 +240,6 @@ export class UserResolver {
|
||||
}
|
||||
|
||||
const user = new User(dbUser)
|
||||
// user.email = email
|
||||
// user.pubkey = dbUser.pubKey.toString('hex')
|
||||
user.language = dbUser.language
|
||||
|
||||
// Elopage Status & Stored PublisherId
|
||||
user.hasElopage = await this.hasElopage({ ...context, user: dbUser })
|
||||
@ -266,10 +260,6 @@ export class UserResolver {
|
||||
})
|
||||
user.coinanimation = coinanimation
|
||||
|
||||
// context.role is not set to the actual role yet on login
|
||||
const countServerUsers = await ServerUser.count({ email: user.email })
|
||||
user.isAdmin = countServerUsers > 0
|
||||
|
||||
context.setHeaders.push({
|
||||
key: 'token',
|
||||
value: encode(dbUser.pubKey),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user