-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify Users' Access Types #357
Conversation
Thanks for contributing! If you've made changes to the API's functionality, please make sure to bump the package version—see this guide to semantic versioning for details—and document those changes as appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put some thoughts down
] | ||
}, standard); | ||
}).rejects.toThrow(ForbiddenError); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add another test making sure the role of the user is not updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The role of the current user making the request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the role of all users in the input of the changes requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is that when an error is thrown, the request should not make changes to the database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if there is any questions regarding for what I requested
services/UserAccountService.ts
Outdated
} | ||
// Prevent anyone from demoting user with current admin status | ||
if (currUser.accessType === UserAccessType.ADMIN && newAccess !== UserAccessType.ADMIN) { | ||
throw new ForbiddenError('You cannot demote an admin.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there's been some use-case of this e.g. at end of school year where we want to remove ADMIN from users who no longer need admin perms. Do we plan on doing this manually? If so, should we also only grand ADMIN permissions manually as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few changes and some ideas needed to be discussed
] | ||
}, standard); | ||
}).rejects.toThrow(ForbiddenError); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the role of all users in the input of the changes requested
] | ||
}, standard); | ||
}).rejects.toThrow(ForbiddenError); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is that when an error is thrown, the request should not make changes to the database
…into nikhil/admin-role-management merging main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to make changes that allows promotion to admin
] | ||
}, standard); | ||
}).rejects.toThrow(ForbiddenError); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if there is any questions regarding for what I requested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good for me now. I will run tests in your branch in a bit. Meanwhile, let's also get Shravan to review this since it is moderately size change.
services/UserAccountService.ts
Outdated
@@ -234,7 +234,6 @@ export default class UserAccountService { | |||
|
|||
const updatedUser = await userRepository.upsertUser(currUser, { accessType }); | |||
|
|||
// log the activity of changing a user's access type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be honest this specific comment is fine as it explains a decent size of code
Also make sure to fix linting |
…into nikhil/admin-role-management merging from master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else looks good - if you fix the two nit I mentioned, I will approve this PR
services/UserAccountService.ts
Outdated
}); | ||
} | ||
|
||
public async getAllUsersWithAccessLevels(): Promise<PrivateProfile[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking, are you thinking that we might have a type for just the user with accesslevels in the future? If that is not the case, we can just change the name of the function to getAllFullUserProfile()
…into nikhil/admin-role-management merging from master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀🚀
Closes #342.
Added
PATCH
route to update user access types.Finalized
GET
route to obtain all users and access types.