fix(user.set): cannot change self permission (#353)

This commit is contained in:
Fabrice Marsaud 2016-06-28 13:28:31 +02:00 committed by Julien Fontanet
parent 1127ec3a90
commit 687809db9d

View File

@ -22,7 +22,7 @@ create.params = {
// Deletes an existing user.
async function delete_ ({id}) {
if (id === this.session.get('user_id')) {
throw new InvalidParameters('an user cannot delete itself')
throw new InvalidParameters('a user cannot delete itself')
}
await this.deleteUser(id)
@ -58,6 +58,9 @@ getAll.permission = 'admin'
// -------------------------------------------------------------------
export async function set ({id, email, password, permission}) {
if (permission && id === this.session.get('user_id')) {
throw new InvalidParameters('a user cannot change it\'s own permission')
}
await this.updateUser(id, {email, password, permission})
}