mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
use getUser helper to get moderator form context
This commit is contained in:
parent
f752d8d045
commit
de6421201d
@ -1,4 +1,4 @@
|
||||
import { Context } from '@/server/context'
|
||||
import { Context, getUser } from '@/server/context'
|
||||
import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx, Int } from 'type-graphql'
|
||||
import {
|
||||
getCustomRepository,
|
||||
@ -143,8 +143,8 @@ export class AdminResolver {
|
||||
throw new Error(`Could not find user with userId: ${userId}`)
|
||||
}
|
||||
// moderator user disabled own account?
|
||||
const moderatorUser = context.user
|
||||
if (moderatorUser && moderatorUser.id === userId) {
|
||||
const moderatorUser = getUser(context)
|
||||
if (moderatorUser.id === userId) {
|
||||
throw new Error('Moderator can not delete his own account!')
|
||||
}
|
||||
// soft-delete user
|
||||
@ -310,8 +310,8 @@ export class AdminResolver {
|
||||
@Ctx() context: Context,
|
||||
): Promise<boolean> {
|
||||
const pendingCreation = await AdminPendingCreation.findOneOrFail(id)
|
||||
const moderatorUser = context.user
|
||||
if (moderatorUser && moderatorUser.id === pendingCreation.userId)
|
||||
const moderatorUser = getUser(context)
|
||||
if (moderatorUser.id === pendingCreation.userId)
|
||||
throw new Error('Moderator can not confirm own pending creation')
|
||||
|
||||
const user = await dbUser.findOneOrFail({ id: pendingCreation.userId }, { withDeleted: true })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user