From a9d688091712991581328eaff90e98766c61c6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Mon, 7 Nov 2011 11:18:42 +0000 Subject: [PATCH] Refactor code for session update on password change (#382) --- .../lib/Lemonldap/NG/Portal/PasswordDBDBI.pm | 7 +------ .../lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm | 8 +------- .../lib/Lemonldap/NG/Portal/Simple.pm | 10 +++++++++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBDBI.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBDBI.pm index 5f7f3e27f..0f2bad4f5 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBDBI.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBDBI.pm @@ -12,7 +12,7 @@ use base qw(Lemonldap::NG::Portal::_DBI ); #inherits Lemonldap::NG::Portal::_SMTP -our $VERSION = '1.1.0'; +our $VERSION = '1.2.0'; ## @apmethod int passwordDBInit() # Load SMTP functions and call DBI authInit() @@ -72,11 +72,6 @@ sub modifyPassword { $self->lmLog( "Password changed for $user", 'debug' ); - # Update password in session if needed - my $infos; - $infos->{_password} = $self->{newpassword}; - $self->updateSession($infos) if ( $self->{storePassword} ); - PE_PASSWORD_OK; } diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm index b79139282..643c2396b 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/PasswordDBLDAP.pm @@ -12,7 +12,7 @@ use Lemonldap::NG::Portal::UserDBLDAP; #inherits #inherits Lemonldap::NG::Portal::_SMTP -our $VERSION = '1.1.0'; +our $VERSION = '1.2.0'; *_formateFilter = *Lemonldap::NG::Portal::UserDBLDAP::formateFilter; *_search = *Lemonldap::NG::Portal::UserDBLDAP::search; @@ -57,12 +57,6 @@ sub modifyPassword { $self->{confirmpassword}, $self->{oldpassword} ); - # Update password in session if needed - my $infos; - $infos->{_password} = $self->{newpassword}; - $self->updateSession($infos) - if ( $self->{storePassword} and $code == PE_PASSWORD_OK ); - return $code unless ( $code == PE_PASSWORD_OK ); # If password policy and force reset, set reset flag diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index ade014a23..dfb1a4d30 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -1855,12 +1855,20 @@ sub modifyPassword { my $res = $self->SUPER::modifyPassword(); - # Continue process if password change is ok if ( $res == PE_PASSWORD_OK ) { + # Update password in session if needed + $self->lmLog( "Update password in session for " . $self->{user}, + 'debug' ); + + my $infos; + $infos->{_password} = $self->{newpassword}; + $self->updateSession($infos) if ( $self->{storePassword} ); + # Set a flag to ignore password change in Menu $self->{ignorePasswordChange} = 1; + # Continue process if password change is ok return PE_OK; }