repair isAuthorized and other user access and findings

This commit is contained in:
Claus-Peter Huebner 2023-07-03 18:43:49 +02:00
parent c324acc5b9
commit e018234591
4 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,7 @@ export const MODERATOR_RIGHTS = [
RIGHTS.DELETE_CONTRIBUTION_LINK,
RIGHTS.UPDATE_CONTRIBUTION_LINK,
RIGHTS.ADMIN_CREATE_CONTRIBUTION_MESSAGE,
RIGHTS.ADMIN_LIST_ALL_CONTRIBUTION_MESSAGES,
RIGHTS.DENY_CONTRIBUTION,
RIGHTS.ADMIN_OPEN_CREATIONS,
]

View File

@ -33,6 +33,7 @@ export const isAuthorized: AuthChecker<Context> = async ({ context }, rights) =>
try {
const user = await User.findOneOrFail({
where: { gradidoID: decoded.gradidoID },
withDeleted: true,
relations: ['emailContact', 'userRoles'],
})
// console.log('isAuthorized user=', user)

View File

@ -134,6 +134,7 @@ export class UserResolver {
logger.info(`login with ${email}, ***, ${publisherId} ...`)
email = email.trim().toLowerCase()
const dbUser = await findUserByEmail(email)
// console.log('login dbUser=', dbUser)
if (dbUser.deletedAt) {
throw new LogError('This user was permanently deleted. Contact support for questions', dbUser)
}

View File

@ -56,7 +56,11 @@ export const userFactory = async (
}
// get last changes of user from database
// dbUser = await User.findOneOrFail({ id }, { withDeleted: true })
dbUser = await User.findOneOrFail({
where: { id },
withDeleted: true,
relations: ['emailContact', 'userRoles'],
})
return dbUser
}