mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Permission checking in user.create().
This commit is contained in:
parent
93bb0e9097
commit
d80ff58bb8
16
src/api.js
16
src/api.js
@ -220,7 +220,21 @@ Api.fn.user = {
|
||||
throw Api.err.INVALID_PARAMS;
|
||||
}
|
||||
|
||||
return this.users.create(p_email, p_pass, p_perm).then(function (user) {
|
||||
var user_id = session.get('user_id');
|
||||
if (undefined === user_id)
|
||||
{
|
||||
throw Api.err.UNAUTHORIZED;
|
||||
}
|
||||
|
||||
var users = this.users;
|
||||
return users.get(user_id).then(function (user) {
|
||||
if (!user.hasPermission('admin'))
|
||||
{
|
||||
throw Api.err.UNAUTHORIZED;
|
||||
}
|
||||
|
||||
return users.create(p_email, p_pass, p_perm);
|
||||
}).then(function (user) {
|
||||
return (''+ user.get('id'));
|
||||
});
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user