Add user form & action

This commit is contained in:
Kload 2013-09-23 13:31:57 +02:00
parent 0f9d9b8de5
commit 6d2755e236
3 changed files with 29 additions and 0 deletions

View file

@ -40,3 +40,7 @@ html, body {
font-weight: bold; font-weight: bold;
line-height: 25px; line-height: 25px;
} }
body .form-control {
padding: 6px;
}

View file

@ -180,6 +180,26 @@ app = Sammy('#main', function (sam) {
}); });
}); });
sam.get('#/users/create', function (c) {
c.api('/domains', function(data) {
c.view('user_create', data);
});
});
sam.post('#/users', function (c) {
if (c.params['password'] == c.params['confirmation']) {
c.params['mail'] = c.params['email'] + '@' + c.params['domain'];
c.api('/users', function(data) {
c.flash('success', 'User successfully created');
c.redirect('#/users');
}, 'POST', c.params.toHash());
} else {
c.flash('fail', "Passwords don't match");
store.clear('slide');
//c.redirect('#/users/create');
}
});
sam.get('#/users/:user', function (c) { sam.get('#/users/:user', function (c) {
c.api('/users/'+ c.params['user'], function(data) { c.api('/users/'+ c.params['user'], function(data) {
c.view('user_info', data); c.view('user_info', data);
@ -208,6 +228,7 @@ app = Sammy('#main', function (sam) {
}, 'PUT', params); }, 'PUT', params);
} }
}); });
sam.get('#/users/:user/delete', function (c) { sam.get('#/users/:user/delete', function (c) {
if (confirm('Are you sure you want to delete '+ c.params['user'] +' ?')) { if (confirm('Are you sure you want to delete '+ c.params['user'] +' ?')) {
c.api('/users/'+ c.params['user'], function(data) { c.api('/users/'+ c.params['user'], function(data) {

View file

@ -13,3 +13,7 @@
{{/Users}} {{/Users}}
</div> </div>
</div> </div>
<div class="text-center">
<a href="#/users/create" class="btn btn-lg btn-success slide"><span class="glyphicon glyphicon-plus"></span> New user</a>
</div>