Better userLogger messages for password change (#2393)

This commit is contained in:
Clément OUDOT 2020-11-29 18:02:13 +01:00
parent fa36ca674c
commit 8211850be7
3 changed files with 12 additions and 4 deletions

View File

@ -13,7 +13,7 @@ use Scalar::Util 'weaken';
use IO::Socket::Timeout;
use utf8;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
our $ppLoaded = 0;
BEGIN {
@ -455,7 +455,7 @@ sub userModifyPassword {
return PE_LDAPERROR;
}
$self->{portal}->userLogger->notice("Password changed for $dn");
$self->{portal}->logger->notice("Password changed for $dn");
# Rebind as manager for next LDAP operations if we were bound as user
$self->bind() if $asUser;
@ -588,8 +588,7 @@ sub userModifyPassword {
return PE_WRONGMANAGERACCOUNT
if ( $mesg->code == 50 || $mesg->code == 8 );
if ( $mesg->code == 0 ) {
$self->{portal}
->userLogger->notice("Password changed $self->{portal}->{user}");
$self->{portal}->logger->notice("Password changed for $dn");
# Rebind as manager for next LDAP operations if we were bound as user
$self->bind() if $asUser;

View File

@ -84,6 +84,10 @@ sub _modifyPassword {
my $res = $self->modifyPassword( $req, $req->data->{newpassword} );
if ( $res == PE_PASSWORD_OK ) {
$self->logger->debug( 'Update password in session for ' . $req->user );
my $userlog = $req->sessionInfo->{ $self->conf->{whatToTrace} };
my $iplog = $req->sessionInfo->{ipAddr};
$self->userLogger->notice("Password changed for $userlog ($iplog)")
if ( defined $userlog and $iplog );
my $infos;
# Store new password if asked

View File

@ -490,6 +490,11 @@ sub changePwd {
return $result;
}
my $userlog = $req->sessionInfo->{ $self->conf->{whatToTrace} };
my $iplog = $req->sessionInfo->{ipAddr};
$self->userLogger->notice("Password changed for $userlog ($iplog)")
if ( defined $userlog and $iplog );
# Send mail containing the new password
$req->data->{mailAddress} ||=
$self->p->getFirstValue(