Fix MailReset for DBI (#1508)

Same todo with other Password::* backends
This commit is contained in:
Xavier Guimard 2018-11-13 11:30:45 +01:00
parent e966399cc0
commit e317d180b9
5 changed files with 48 additions and 34 deletions

View File

@ -16,6 +16,36 @@ our $VERSION = '2.0.0';
# PROPERTIES
has table => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return $conf->{dbiUserTable} || $conf->{dbiAuthTable};
}
);
has pivot => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return $conf->{userPivot} || $conf->{dbiAuthLoginCol};
}
);
has mailField => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return
$conf->{dbiMailCol}
|| $conf->{userPivot}
|| $conf->{dbiAuthLoginCol};
}
);
# _dbh object: DB connection object
has _dbh => (
is => 'rw',

View File

@ -20,9 +20,9 @@ sub confirm {
}
sub modifyPassword {
my ( $self, $req, $pwd ) = @_;
my ( $self, $req, $pwd, $useMail ) = @_;
my $userCol = $self->conf->{dbiAuthLoginCol};
my $userCol = $useMail ? $self->mailField : $self->pivot;
my $passwordCol = $self->conf->{dbiAuthPasswordCol};
my $table = $self->conf->{dbiAuthTable};
my $dynamicHash = $self->conf->{dbiDynamicHashEnabled} || 0;

View File

@ -425,7 +425,8 @@ sub changePwd {
# Populate $req->{user} for logging purpose
my $tmp = $self->conf->{portalRequireOldPassword};
$self->conf->{portalRequireOldPassword} = 0;
my $result = $self->p->_passwordDB->modifyPassword($req);
$req->user($req->{sessionInfo}->{_user} );
my $result = $self->p->_passwordDB->modifyPassword($req, $req->data->{newpassword},1);
$req->{user} = undef;
# Mail token can be used only one time, delete the session if all is ok

View File

@ -10,36 +10,6 @@ our $VERSION = '2.0.0';
# PROPERTIES
has table => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return $conf->{dbiUserTable} || $conf->{dbiAuthTable};
}
);
has pivot => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return $conf->{userPivot} || $conf->{dbiAuthLoginCol};
}
);
has mailField => (
is => 'rw',
lazy => 1,
builder => sub {
my $conf = $_[0]->{conf};
return
$conf->{dbiMailCol}
|| $conf->{userPivot}
|| $conf->{dbiAuthLoginCol};
}
);
has exportedVars => (
is => 'rw',
lazy => 1,

View File

@ -11,7 +11,7 @@ BEGIN {
}
my ( $res, $user, $pwd );
my $maintests = 7;
my $maintests = 8;
my $mailSend = 0;
my $mail2 = 0;
@ -101,6 +101,19 @@ SKIP: {
ok( mail() =~ /Your password was changed/, 'Password was changed' );
ok(
$res = $client->_post(
'/',
IO::String->new('user=dwho&password=zz&test=sql'),
length => 30
),
'Auth query'
);
expectOK($res);
my $id = expectCookie($res);
$client->logout($id);
#print STDERR Dumper($query);
}