Skip to content

Commit

Permalink
fix:(login) Admin should be able to login after signup #579 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanoathos authored Oct 18, 2024
1 parent 857a9e6 commit d3f9075
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/resolvers/userResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,18 @@ const resolvers: any = {
admin: user.id,
})

if (user?.role === RoleOfUser.ADMIN && organization) {
const token = generateToken(user._id, user._doc?.role || 'user')
const data = {
token: token,
user: user.toJSON(),
}
return data
} else if (user?.role === RoleOfUser.MANAGER) {
if (user?.role === RoleOfUser.ADMIN) {
if (user?.organizations?.includes(org?.name)) {
const token = generateToken(user._id, user._doc?.role || 'user');
const data = {
token: token,
user: user.toJSON(),
};
return data;
} else {
throw new Error('You do not have access to this organization.');
}
} else if (user?.role === RoleOfUser.MANAGER) {
const program: any = await Program.find({
manager: user.id,
}).populate({
Expand Down

0 comments on commit d3f9075

Please sign in to comment.