Skip to content

Create ability for Admins to promote and demote Admins #1486

@trillium

Description

@trillium

Overview

Right now the only avenue to promote a user to admin level is to ping someone with DB access and have them promote the account. Not ideal.

Action Items

The EditUser accessible by an admin needs the ability to promote and demote admins. Here's the short list:

PR Needs

  • Promote a user to an admin
  • Remove a user's admin status
  • Remove self admin status

This will require both front end and back end edits

Front end edits:

  • Create AdminStatus component rendered on the EditUsers page
    • Displays text: "VRMS Admin" and toggle component.
// client/src/components/user-admin/EditUsers.js
<FormGroup>
  <FormControlLabel control={<Switch checked={isActive} />} onClick={() => handleSetIsActive()} />
</FormGroup>
  • Create function within UserApiService:
    • UpdateUserAdminStatus
      This function edits the user's admin status and stores the the user id _id of the admin that promoted them.

Back end edits:

  • update user.model.js to have an adminPromotedBy property of type string
  • apply the update to the user model to across the db

Resources

This task is fairly similar to #1452 , so feel free to use that PR's code as a model for how to do this PR.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Final QA (product)

Relationships

None yet

Development

No branches or pull requests

Issue actions