Skip to content

Commit

Permalink
fixed bug for email array being out of order
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-dange committed Jul 8, 2023
1 parent d07b429 commit 25a19d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/validators/AdminControllerRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ export class ModifyUserAccessLevelRequest implements IModifyUserAccessLevelReque
@IsDefined()
@ArrayNotEmpty()
accessUpdates: UserAccessUpdates[];


}
3 changes: 2 additions & 1 deletion services/UserAccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ export default class UserAccountService {
throw new BadRequestError(`Couldn't find accounts matching these emails: ${emailsNotFound}`);
}


const updatedUsers = await Promise.all(accessUpdates.map(async (accessUpdate, index) => {
const { user, newAccess } = accessUpdate;
const { accessType } = newAccess;
const currUser = users[index];
const currUser = await userRepository.findByEmail(user);
// Prevent anyone from promoting user to admin
if (accessType === UserAccessType.ADMIN) {
throw new ForbiddenError('You cannot promote users to admin.');
Expand Down

0 comments on commit 25a19d1

Please sign in to comment.