mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Use PASSWORD_MIN_LENGTH constant.
This commit is contained in:
parent
163cbdb4c7
commit
3642835745
4 changed files with 14 additions and 5 deletions
|
@ -3,6 +3,8 @@
|
||||||
var app = Sammy.apps['#main'];
|
var app = Sammy.apps['#main'];
|
||||||
var store = app.store;
|
var store = app.store;
|
||||||
|
|
||||||
|
var PASSWORD_MIN_LENGTH = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Users
|
* Users
|
||||||
*
|
*
|
||||||
|
@ -18,6 +20,10 @@
|
||||||
// Create user form
|
// Create user form
|
||||||
app.get('#/users/create', function (c) {
|
app.get('#/users/create', function (c) {
|
||||||
c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('/domains', function(data) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
||||||
|
|
||||||
|
// Password min length
|
||||||
|
data.password_min_length = PASSWORD_MIN_LENGTH;
|
||||||
|
|
||||||
c.view('user/user_create', data);
|
c.view('user/user_create', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +31,7 @@
|
||||||
// Create user (POST)
|
// Create user (POST)
|
||||||
app.post('#/users/create', function (c) {
|
app.post('#/users/create', function (c) {
|
||||||
if (c.params['password'] == c.params['confirmation']) {
|
if (c.params['password'] == c.params['confirmation']) {
|
||||||
if (c.params['password'].length < 4) {
|
if (c.params['password'].length < PASSWORD_MIN_LENGTH) {
|
||||||
c.flash('fail', y18n.t('password_too_short'));
|
c.flash('fail', y18n.t('password_too_short'));
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
}
|
}
|
||||||
|
@ -62,6 +68,9 @@
|
||||||
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_info_get_0
|
c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_info_get_0
|
||||||
c.api('/domains', function(dataDomains) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
c.api('/domains', function(dataDomains) { // http://api.yunohost.org/#!/domain/domain_list_get_2
|
||||||
|
|
||||||
|
// Password min length
|
||||||
|
data.password_min_length = PASSWORD_MIN_LENGTH;
|
||||||
|
|
||||||
// User email use a fake splitted field
|
// User email use a fake splitted field
|
||||||
email = data.mail.split('@');
|
email = data.mail.split('@');
|
||||||
data.email = {
|
data.email = {
|
||||||
|
@ -152,7 +161,7 @@
|
||||||
} else {
|
} else {
|
||||||
if (params['password']) {
|
if (params['password']) {
|
||||||
if (params['password'] == params['confirmation']) {
|
if (params['password'] == params['confirmation']) {
|
||||||
if (params['password'].length < 4) {
|
if (params['password'].length < PASSWORD_MIN_LENGTH) {
|
||||||
c.flash('fail', y18n.t('password_too_short'));
|
c.flash('fail', y18n.t('password_too_short'));
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
c.redirect('#/users/'+ c.params['user'] + '/edit');
|
c.redirect('#/users/'+ c.params['user'] + '/edit');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"administration_password" : "Administration password",
|
"administration_password" : "Administration password",
|
||||||
"password_confirmation" : "Password confirmation",
|
"password_confirmation" : "Password confirmation",
|
||||||
"password_new" : "New password",
|
"password_new" : "New password",
|
||||||
"password_description" : "Password must be at least 4 characters long.",
|
"password_description" : "Password must be at least %s characters long.",
|
||||||
"login" : "Login",
|
"login" : "Login",
|
||||||
"logout" : "Logout",
|
"logout" : "Logout",
|
||||||
"loading" : "Loading …",
|
"loading" : "Loading …",
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
|
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input type="password" id="confirmation" name="confirmation" class="form-control" placeholder="•••••" required>
|
<input type="password" id="confirmation" name="confirmation" class="form-control" placeholder="•••••" required>
|
||||||
<div class="help-block">{{t 'password_description'}}</div>
|
<div class="help-block">{{t 'password_description' password_min_length}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
|
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input type="password" id="confirmation" name="confirmation" class="form-control" placeholder="•••••">
|
<input type="password" id="confirmation" name="confirmation" class="form-control" placeholder="•••••">
|
||||||
<div class="help-block">{{t 'password_description'}}</div>
|
<div class="help-block">{{t 'password_description' password_min_length}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue