mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] #16 Allow admin to force user password in edit form.
This commit is contained in:
parent
741dafbe00
commit
4b4a701b66
2 changed files with 40 additions and 6 deletions
32
js/app.js
32
js/app.js
|
@ -399,7 +399,7 @@ app = Sammy('#main', function (sam) {
|
|||
sam.post('#/users', function (c) {
|
||||
if (c.params['password'] == c.params['confirmation']) {
|
||||
if (c.params['password'].length < 4) {
|
||||
c.flash('fail', "Passwords is too short");
|
||||
c.flash('fail', "Password is too short");
|
||||
store.clear('slide');
|
||||
}
|
||||
else {
|
||||
|
@ -430,16 +430,36 @@ app = Sammy('#main', function (sam) {
|
|||
sam.put('#/users/:user', function (c) {
|
||||
params = {}
|
||||
$.each(c.params.toHash(), function(key, value) {
|
||||
if (value !== '' && value !== 'user') { params[key] = value; }
|
||||
if (value !== '' && key !== 'user') { params[key] = value; }
|
||||
});
|
||||
|
||||
if ($.isEmptyObject(params)) {
|
||||
c.flash('fail', 'You should modify something');
|
||||
store.clear('slide');
|
||||
c.redirect('#/users/'+ c.params['user'] + '/edit');
|
||||
// c.redirect('#/users/'+ c.params['user'] + '/edit');
|
||||
} else {
|
||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_update_put_1
|
||||
c.redirect('#/users/'+ c.params['user']);
|
||||
}, 'PUT', params);
|
||||
if (params['password']) {
|
||||
if (params['password'] == params['confirmation']) {
|
||||
if (params['password'].length < 4) {
|
||||
c.flash('fail', "Password is too short");
|
||||
store.clear('slide');
|
||||
}
|
||||
else {
|
||||
params['change_password'] = params['password'];
|
||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_update_put_1
|
||||
c.redirect('#/users/'+ c.params['user']);
|
||||
}, 'PUT', params);
|
||||
}
|
||||
} else {
|
||||
c.flash('fail', "Passwords don't match");
|
||||
store.clear('slide');
|
||||
}
|
||||
}
|
||||
else {
|
||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_update_put_1
|
||||
c.redirect('#/users/'+ c.params['user']);
|
||||
}, 'PUT', params);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -34,6 +34,20 @@
|
|||
<input type="email" name="mail" class="form-control" placeholder="{{Mail}}">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
<label for="password" class="col-sm-3 control-label">Password</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="password" name="password" class="form-control" placeholder="•••••">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirmation" class="col-sm-3 control-label">Confirmation</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="password" name="confirmation" class="form-control" placeholder="•••••">
|
||||
<div class="help-block">Password must be at least 4 characters long.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue