Manually place user location on main map
This commit is contained in:
@@ -112,7 +112,7 @@ export class UserRoutes {
|
||||
const isSelf = _id === req.user._id
|
||||
const isAdmin = req.user.administrator
|
||||
|
||||
// User can see themselves, otherwise must be super user
|
||||
// User can see themselves, otherwise must be admin
|
||||
if (!isSelf && !isAdmin) {
|
||||
throw createError.Forbidden()
|
||||
}
|
||||
@@ -185,8 +185,8 @@ export class UserRoutes {
|
||||
throw createError.Forbidden()
|
||||
}
|
||||
|
||||
if (isSelf && !isAdmin) {
|
||||
throw createError.BadRequest("Cannot modify own administrator level")
|
||||
if (isSelf && isAdmin && !req.body.administrator) {
|
||||
throw createError.BadRequest("Cannot remove own administrator level")
|
||||
}
|
||||
|
||||
const User = this.db.User
|
||||
@@ -199,7 +199,7 @@ export class UserRoutes {
|
||||
// We don't allow direct updates to the email field so remove it if present
|
||||
const userUpdates = new User(req.body)
|
||||
|
||||
delete userUpdates.email
|
||||
userUpdates.email = undefined
|
||||
|
||||
user.merge(userUpdates)
|
||||
const savedUser = await user.save()
|
||||
|
||||
Reference in New Issue
Block a user