openrank-backend icon indicating copy to clipboard operation
openrank-backend copied to clipboard

User Role

Open pbteja1998 opened this issue 6 years ago • 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 be id. But created_at and updated_at fields are not necessary). This enum should have two entries for now - Candidate and Admin.
  • A user should be able to have many roles.
  • Make sure that user will have a Candidate role when the user registers through api/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 avatar Sep 10 '19 22:09 pbteja1998

@pbteja1998 is this open to work on?

debamitra avatar Sep 13 '19 20:09 debamitra

Yes.

pbteja1998 avatar Sep 13 '19 20:09 pbteja1998

@debamitra Shall I assign it to you?

pbteja1998 avatar Sep 13 '19 20:09 pbteja1998

@pbteja1998 yes.

debamitra avatar Sep 13 '19 20:09 debamitra

Open a WIP draft PR while developing.

pbteja1998 avatar Sep 13 '19 20:09 pbteja1998

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"

nitinrgoyal avatar Sep 14 '19 07:09 nitinrgoyal

@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

debamitra avatar Oct 09 '19 12:10 debamitra

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

krushiraj avatar Oct 09 '19 15:10 krushiraj