[enh] Use PASSWORD_MIN_LENGTH constant.

This commit is contained in:
opi 2016-04-29 13:37:27 +02:00
parent 163cbdb4c7
commit 3642835745
4 changed files with 14 additions and 5 deletions

View file

@ -3,6 +3,8 @@
var app = Sammy.apps['#main'];
var store = app.store;
var PASSWORD_MIN_LENGTH = 4;
/**
* Users
*
@ -18,6 +20,10 @@
// Create user form
app.get('#/users/create', function (c) {
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);
});
});
@ -25,7 +31,7 @@
// Create user (POST)
app.post('#/users/create', function (c) {
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'));
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('/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
email = data.mail.split('@');
data.email = {
@ -152,7 +161,7 @@
} else {
if (params['password']) {
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'));
store.clear('slide');
c.redirect('#/users/'+ c.params['user'] + '/edit');

View file

@ -5,7 +5,7 @@
"administration_password" : "Administration password",
"password_confirmation" : "Password confirmation",
"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",
"logout" : "Logout",
"loading" : "Loading …",

View file

@ -65,7 +65,7 @@
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
<div class="col-sm-9">
<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>

View file

@ -89,7 +89,7 @@
<label for="confirmation" class="col-sm-3 control-label">{{t 'password_confirmation'}}</label>
<div class="col-sm-9">
<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>