From e01823459131be39b43717b9e722082a63ffa52f Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Mon, 3 Jul 2023 18:43:49 +0200 Subject: [PATCH] repair isAuthorized and other user access and findings --- backend/src/auth/MODERATOR_RIGHTS.ts | 1 + backend/src/graphql/directive/isAuthorized.ts | 1 + backend/src/graphql/resolver/UserResolver.ts | 1 + backend/src/seeds/factory/user.ts | 6 +++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/auth/MODERATOR_RIGHTS.ts b/backend/src/auth/MODERATOR_RIGHTS.ts index 7c892b903..1ff689de6 100644 --- a/backend/src/auth/MODERATOR_RIGHTS.ts +++ b/backend/src/auth/MODERATOR_RIGHTS.ts @@ -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, ] diff --git a/backend/src/graphql/directive/isAuthorized.ts b/backend/src/graphql/directive/isAuthorized.ts index 20efb0cb9..fcee2d19e 100644 --- a/backend/src/graphql/directive/isAuthorized.ts +++ b/backend/src/graphql/directive/isAuthorized.ts @@ -33,6 +33,7 @@ export const isAuthorized: AuthChecker = async ({ context }, rights) => try { const user = await User.findOneOrFail({ where: { gradidoID: decoded.gradidoID }, + withDeleted: true, relations: ['emailContact', 'userRoles'], }) // console.log('isAuthorized user=', user) diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 787ea2081..f96389f77 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -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) } diff --git a/backend/src/seeds/factory/user.ts b/backend/src/seeds/factory/user.ts index 82b44c6d9..721360b8a 100644 --- a/backend/src/seeds/factory/user.ts +++ b/backend/src/seeds/factory/user.ts @@ -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 }