add in backend function unDeleteUser()

This commit is contained in:
ogerly 2022-02-18 15:02:49 +01:00 committed by Ulf Gebhardt
parent fed3562e4d
commit fc3d7e2cbb
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 15 additions and 1 deletions

View File

@ -1,7 +1,7 @@
import gql from 'graphql-tag'
export const unDeleteUser = gql`
mutation ($userId: Int!) {
mutation ($userId: Float!) {
unDeleteUser(userId: $userId)
}
`

View File

@ -27,4 +27,5 @@ export enum RIGHTS {
CONFIRM_PENDING_CREATION = 'CONFIRM_PENDING_CREATION',
SEND_ACTIVATION_EMAIL = 'SEND_ACTIVATION_EMAIL',
DELETE_USER = 'DELETE_USER',
UNDELETE_USER = 'UNDELETE_USER',
}

View File

@ -114,6 +114,19 @@ export class AdminResolver {
return true
}
@Authorized([RIGHTS.UNDELETE_USER])
@Mutation(() => Boolean)
async unDeleteUser(@Arg('userId') userId: number): Promise<boolean> {
const user = await User.findOne({ id: userId }, { withDeleted: true })
// user exists ?
if (!user) {
throw new Error(`Could not find user with userId: ${userId}`)
}
// recover user account
await user.recover()
return true
}
@Authorized([RIGHTS.CREATE_PENDING_CREATION])
@Mutation(() => [Number])
async createPendingCreation(