-
-
Notifications
You must be signed in to change notification settings - Fork 189
Conversation
server/controllers/users/profile.js
Outdated
* Take Admin priveleges away from User | ||
*/ | ||
export const demote = async function(req, res) { | ||
if (req.params.userId === req.user._id) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
I'm not great at design either, but maybe it could be a checkbox in with the rest of the form? |
6d23e54
to
fd3ad97
Compare
The toggle is now a checkbox. Remember thinking earlier that it would be better to have the toggle separate from the edit user form, but I can't remember why, so it must not have been a very good reason. This PR is now dependent on #341. Something I had to fix to get this to work. |
Cool, it looks a bit weird with the label above and nothing next to the checkbox though, you can add text next to the checkbox with It also complains |
fd3ad97
to
0cfdea1
Compare
Oh right. I removed the label and put text next to the checkbox. |
client/modules/users/userReducer.js
Outdated
|
||
export const promoteUser = userId => ({ | ||
[CALL_API]: { | ||
endpoint: `admin/users/${userId}/promote`, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
0cfdea1
to
9a81e58
Compare
I finished cleaning up the old routes. |
@@ -50,6 +51,17 @@ export const update = async function(req, res) { | |||
if (sameEmail && sameEmail._id !== req.user._id) | |||
throw new BadRequestError('Email address is taken') | |||
|
|||
// Update admin status |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
9a81e58
to
0698f2b
Compare
// Update admin status | ||
if (includes(req.user, ADMIN_ROLE)) { | ||
const alreadyAdmin = includes(user.roles, ADMIN_ROLE) | ||
if (user.isAdmin && !alreadyAdmin) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This adds the ability to promote/demote users to/from admin status. Admins can't demote themselves. Although they're not prevented from trying, only told after the fact that they can't with an error message.
Could use some input on design/where exactly you want this feature. I'm real bad at design.