admins can create users from admin/users panel

This commit is contained in:
Baris Soner Usakli
2013-12-23 13:27:26 -05:00
parent 2c8725558e
commit 3bd8cf69a1
5 changed files with 98 additions and 3 deletions

View File

@@ -64,6 +64,39 @@ define(function() {
});
}
function handleUserCreate() {
$('#createUser').on('click', function() {
$('#create-modal').modal('show');
});
$('#create-modal-go').on('click', function() {
var username = $('#create-user-name').val(),
email = $('#create-user-email').val(),
password = $('#create-user-password').val(),
passwordAgain = $('#create-user-password-again').val(),
errorEl = $('#create-modal-error');
if(password !== passwordAgain) {
return errorEl.html('<strong>Error</strong><p>Passwords must match!</p>').removeClass('hide');
}
var user = {
username: username,
email: email,
password: password
};
socket.emit('api:admin.user.createUser', user, function(err, data) {
if(err) {
return errorEl.html('<strong>Error</strong><p>' + err + '</p>').removeClass('hide');
}
$('#create-modal').modal('hide');
app.alert();
});
});
}
jQuery('document').ready(function() {
@@ -99,6 +132,8 @@ define(function() {
initUsers();
handleUserCreate();
socket.removeAllListeners('api:admin.user.search');
socket.on('api:admin.user.search', function(data) {