User Role
Opened this issue · 8 comments
Is your feature request related to a problem? Please describe.
A user should be able to have different roles(Admin
, Candidate
, ContestManager
, ...etc). Right now there is no way to assign a role to the user.
Describe the solution you'd like
- Create a separate model as
Role
. - Role will only have one field
value
which is of type enum(There will also beid
. Butcreated_at
andupdated_at
fields are not necessary). This enum should have two entries for now -Candidate
andAdmin
. - A user should be able to have many roles.
- Make sure that user will have a
Candidate
role when the user registers throughapi/register
route. - Add a separate api to add a role to the user (
POST /api/users/:id/roles
). - Add a separate api to remove a role from the user. (
DELETE /api/users/:id/roles/:role_id
)
@pbteja1998 is this open to work on?
Yes.
@debamitra Shall I assign it to you?
@pbteja1998 yes.
Open a WIP draft PR while developing.
As per my understanding, OpenRank will be used by companies in-house. In that case, there should be 3 roles.
- Admin should be some person who is setting up the system i.e. putting in their company logo, is able to see stats at company level and do such other things (in case of HackerEarth admin was able to see used credits, credit addition history but those are not relevant here. Still we may have some information to share or to change server settings.)
- Test Manager should be a person who is creating tests & questions. Plus coordinating everything i.e. moving people to interview and things like that.
- Candidate is a person who takes test. And may be see result, if possible.
- User may signup using "/recruit/signup" as an Admin or "/signup" as a candidate. Every admin is also given candidate role, by default.
- Test Manager can only be made by Admin. The test manager is also given candidate role.
- Candidates will login using "/login" page while recruiter (Admin / Test Manager) will login from "/recruit/login" page.
- Admin may Create User with Test Manager role - post "/api/users"
@pbteja1998 @nitinrgoyal
Have raised a Draft PR for this issue, please provide some feedback on what needs to change.
Are we also writing some tests?
Make sure that user will have a Candidate role when the user registers through api/register route. - this one is still pending
It's good to have tests written for this project. I guess we should mandate to write tests for anything that is added so that it won't break anything existing in the future.
I suggest to go with Mocha or Jest. Any thoughts @pbteja1998 @nitinrgoyal