* [LEMONLDAP-412] Password policy expiration warning time is now friendly diplayed

This commit is contained in:
Sandro Cazzaniga 2012-07-16 09:58:27 +00:00
parent 2a24913d0c
commit 17d0f0a557
4 changed files with 34 additions and 5 deletions

View File

@ -1456,6 +1456,32 @@ sub stamp {
return $self->{cipher} ? $self->{cipher}->encrypt( time() ) : 1;
}
## @method string convertSec(int sec)
# Convert seconds to hours, minutes, seconds
# @param $sec number of seconds
# @return a formated time
sub convertSec {
my ( $self, $sec ) = splice @_;
# If we only have seconds
return "00:00:$sec" if ( $sec < 60 );
# Calculate the minutes
my $min = $sec / 60, $sec %= 60;
$min = int($min);
return "00:$min:$sec" if ( $min < 60 );
# Calculate the hours
my $hrs = $min / 60, $min %= 60;
$hrs = int($hrs);
return "$hrs:$min:$sec" if ( $hrs < 24 );
# Calculate the days
my $days = $hrs / 24, $hrs %= 24;
$days = int($days);
return "$days:$hrs:$min:$sec" if ( $days < 365 );
}
###############################################################
# MAIN subroutine: call all steps until one returns something #
# different than PE_OK #

View File

@ -175,7 +175,7 @@ sub userBind {
}
if ( $resp->time_before_expiration ) {
$self->{portal}->info( "<h3>"
. $resp->time_before_expiration . " "
. $self->convertSec($resp->time_before_expiration) . " "
. $self->msg(PM_PP_EXP_WARNING)
. "</h3>" );
}

View File

@ -163,7 +163,7 @@ sub error_fr {
'Mot de passe trop récent',
'Mot de passe utilisé trop récemment',
' authentifications restantes, changez votre mot de passe !',
' secondes avant expiration de votre mot de passe, pensez à le changer !',
' avant expiration de votre mot de passe, pensez à le changer !',
'Les mots de passe ne correspondent pas',
'Le mot de passe a été changé',
'Vous avez un nouveau message',
@ -249,7 +249,7 @@ sub error_en {
'Password too young',
'Password used too recently',
' authentications remaining, change your password!',
' seconds before password expiration, change it!',
' before password expiration, change it!',
'Passwords mismatch',
'Password successfully changed',
'You have a new message',
@ -336,7 +336,7 @@ sub error_ro {
'Prea parolă nouă',
'Parola folosit prea recent',
' authentications rămase, schimbaţi-vă parola!',
' secunde înainte de expirarea parola dvs., asiguraţi-vă pentru a schimba!',
' înainte de expirarea parola dvs., asiguraţi-vă pentru a schimba!',
'Parolele nu se potrivesc',
'Parola a fost schimbată',
'Ai un mesaj nou',

View File

@ -5,7 +5,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 10;
use Test::More tests => 11;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
@ -94,3 +94,6 @@ ok( $p->process > 0, 'User OK' );
# Cookie test
ok( $p->{cookie}->[0]->value eq '1', 'Cookie value' );
# convertSec test
ok($p->convertSec(650) eq '00:10:50', 'convertSec');