Manually place user location on main map

This commit is contained in:
John Lyon-Smith
2018-06-27 22:34:21 -07:00
parent e60801ec3e
commit 6f0423bb46
14 changed files with 97 additions and 70 deletions

View File

@@ -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()