3
0

Ajout de la vérification des mots de passe à l'inscription.

This commit is contained in:
Philippe Pittoli 2014-02-08 16:14:41 +01:00
parent 6d75a31f88
commit 0d6d8db6dd

View File

@ -520,27 +520,30 @@ prefix '/user' => sub {
# add a user => registration # add a user => registration
post '/add/' => sub { post '/add/' => sub {
if ( param('login') && param('password') ) { unless ( param('login') && param('password') && param('password2') ) {
session errmsg => q/Identifiant ou mot de passe non renseigné./;
redirect '/user/subscribe';
return;
}
my $pass = sha256_hex(param('password')); unless ( param('password') eq param('password2')) {
session errmsg => q/Les mots de passes ne sont pas identiques./;
redirect '/user/subscribe';
return;
}
my $app = initco(); my $pass = sha256_hex(param('password'));
my ($success) = $app->register_user(param('login')
, $pass);
if($success) { my $app = initco();
session login => param('login'); my ($success) = $app->register_user(param('login'), $pass);
session password => $pass;
redirect '/user/home';
}
else {
session errmsg => q/Ce pseudo est déjà pris./;
redirect '/user/subscribe';
}
if($success) {
session login => param('login');
session password => $pass;
redirect '/user/home';
} }
else { else {
session errmsg => q/login ou password non renseignés/; session errmsg => q/Ce pseudo est déjà pris./;
redirect '/user/subscribe'; redirect '/user/subscribe';
} }