Send dn when resetting LDAP password

Fixes: #1353
This commit is contained in:
Xavier Guimard 2018-01-25 15:53:52 +01:00
parent 057a8afcb2
commit 252ac57692
5 changed files with 17 additions and 11 deletions

View File

@ -2,7 +2,8 @@ package Lemonldap::NG::Portal::Password::LDAP;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_PASSWORD_OK PE_LDAPERROR);
use Lemonldap::NG::Portal::Main::Constants
qw(PE_PASSWORD_OK PE_LDAPERROR PE_ERROR);
extends 'Lemonldap::NG::Portal::Lib::LDAP',
'Lemonldap::NG::Portal::Password::Base';
@ -23,10 +24,15 @@ sub confirm {
sub modifyPassword {
my ( $self, $req, $pwd ) = @_;
my $dn = $req->userData->{_dn} || $req->sessionInfo->{_dn};
unless ($dn) {
$self->logger->error('"dn" is not set, aborting password modification');
return PE_ERROR;
}
# Call the modify password method
my $code = $self->ldap->userModifyPassword( $req->userData->{_dn},
$pwd, $req->datas->{oldpassword} );
my $code =
$self->ldap->userModifyPassword( $dn, $pwd, $req->datas->{oldpassword} );
unless ( $code == PE_PASSWORD_OK ) {
$self->ldap->unbind;
@ -40,7 +46,7 @@ sub modifyPassword {
and $self->conf->{ldapUsePasswordResetAttribute} )
{
my $result = $self->ldap->modify(
$req->datas->{dn},
$dn,
replace => {
$self->conf->{ldapPasswordResetAttribute} =>
$self->conf->{ldapPasswordResetAttributeValue}

View File

@ -325,7 +325,7 @@ sub _reset {
$body =~ s/\$expMailDate/$req->datas->{expMailDate}/ge;
$body =~ s/\$expMailTime/$req->datas->{expMailTime}/ge;
$body =~ s/\$url/$url/g;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1}/ge;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1} || ''/ge;
# Send mail
unless (
@ -443,7 +443,7 @@ sub changePwd {
# Replace variables in body
my $password = $req->datas->{newpassword};
$body =~ s/\$password/$password/g;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1}/ge;
$body =~ s/\$(\w+)/$req->{sessionInfo}->{$1} || ''/ge;
# Send mail
return PE_MAILERROR

View File

@ -35,7 +35,7 @@ SKIP: {
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'debug',
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'DBI',
@ -102,8 +102,8 @@ SKIP: {
#print STDERR Dumper($query);
}
eval { unlink 't/userdb.db' };
count($maintests);
clean_sessions();
done_testing( count() );

View File

@ -28,7 +28,7 @@ SKIP: {
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'debug',
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'LDAP',

View File

@ -25,7 +25,7 @@ SKIP: {
my $client = LLNG::Manager::Test->new(
{
ini => {
logLevel => 'debug',
logLevel => 'error',
useSafeJail => 1,
portalDisplayRegister => 1,
authentication => 'Demo',