Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Commit

Permalink
Fix "incorrectly sets user group to 'user' when not specified in PUT …
Browse files Browse the repository at this point in the history
…method".
  • Loading branch information
RainEggplant committed Sep 25, 2018
1 parent 4397f79 commit cc65668
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ router.put("/:id", verifyToken, async (req, res) => {
return res.status(404).send("404 Not Found: User does not exist.");
}

req.body.group = req.body.group === "admin" ? "admin" : "user";
if (!req.body.group) {
req.body.group = user.group;
} else {
req.body.group = req.body.group === "admin" ? "admin" : "user";
}
// 当跨用户修改或添加管理员权限时,需要管理员权限。
// 修改真实姓名和学号也需要管理员权限。
if (!isAdmin) {
Expand Down

0 comments on commit cc65668

Please sign in to comment.