Fix password reset with DBI (#536)

This commit is contained in:
Clément Oudot 2012-09-25 15:22:50 +00:00
parent 290a4ce0e8
commit c8625a966d

View File

@ -9,7 +9,7 @@ use strict;
use Lemonldap::NG::Portal::Simple;
use Lemonldap::NG::Portal::_DBI; #inherits
our $VERSION = '1.0.0';
our $VERSION = '1.2.3';
## @apmethod int userDBInit()
# Set default values
@ -65,6 +65,31 @@ sub getUser {
$self->lmLog( "User $user not found", 'notice' );
return PE_BADCREDENTIALS;
}
# In mail process, get user value
if ( $self->{mail} ) {
$table = $self->{dbiAuthTable};
$pivot = $self->{dbiAuthLoginCol};
$user = $self->{entry}->{ $self->{userPivot} };
eval {
$sth = $dbh->prepare("SELECT * FROM $table WHERE $pivot=?");
$sth->execute($user);
};
if ($@) {
$self->lmLog( "DBI error: $@", 'error' );
return PE_ERROR;
}
my $results;
unless ( $results = $sth->fetchrow_hashref() ) {
$self->lmLog( "User $user not found", 'notice' );
return PE_BADCREDENTIALS;
}
$self->{user} = $results->{$pivot};
}
PE_OK;
}
@ -74,6 +99,9 @@ sub getUser {
sub setSessionInfo {
my $self = shift;
# Set _user unless already defined
$self->{sessionInfo}->{_user} ||= $self->{user};
# Return if no data to collect
return PE_OK
unless ( $self->{exportedVars}