Reinitialize token when login fails (#1140)

This commit is contained in:
Xavier Guimard 2017-03-14 17:26:07 +00:00
parent b3d15760d2
commit 43437a5244
2 changed files with 4 additions and 0 deletions

View File

@ -50,10 +50,12 @@ sub getUser {
# If connection isn't available, error is displayed by dbh() # If connection isn't available, error is displayed by dbh()
$self->logger->error("DBI error: $@") if ( $self->_dbh ); $self->logger->error("DBI error: $@") if ( $self->_dbh );
eval { $self->p->_authentication->setSecurity($req) };
return PE_ERROR; return PE_ERROR;
} }
unless ( $req->datas->{entry} = $sth->fetchrow_hashref() ) { unless ( $req->datas->{entry} = $sth->fetchrow_hashref() ) {
$self->userLogger->warn("User $user not found"); $self->userLogger->warn("User $user not found");
eval { $self->p->_authentication->setSecurity($req) };
return PE_BADCREDENTIALS; return PE_BADCREDENTIALS;
} }
PE_OK; PE_OK;

View File

@ -56,11 +56,13 @@ sub getUser {
} }
if ( $mesg->count() > 1 ) { if ( $mesg->count() > 1 ) {
$self->logger->error('More than one entry returned by LDAP directory'); $self->logger->error('More than one entry returned by LDAP directory');
eval { $self->p->_authentication->setSecurity($req) };
return PE_BADCREDENTIALS; return PE_BADCREDENTIALS;
} }
unless ( $req->datas->{entry} = $mesg->entry(0) ) { unless ( $req->datas->{entry} = $mesg->entry(0) ) {
my $user = $req->{mail} || $req->{user}; my $user = $req->{mail} || $req->{user};
$self->userLogger->warn("$user was not found in LDAP directory"); $self->userLogger->warn("$user was not found in LDAP directory");
eval { $self->p->_authentication->setSecurity($req) };
return PE_BADCREDENTIALS; return PE_BADCREDENTIALS;
} }
$req->datas->{dn} = $req->datas->{entry}->dn(); $req->datas->{dn} = $req->datas->{entry}->dn();