lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/DBI.pm

50 lines
1014 B
Perl
Raw Normal View History

2016-05-19 07:11:50 +02:00
package Lemonldap::NG::Portal::Auth::DBI;
use strict;
use Mouse;
2016-05-22 14:22:59 +02:00
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_BADCREDENTIALS);
2016-05-19 07:11:50 +02:00
2021-02-01 22:30:37 +01:00
our $VERSION = '2.0.12';
2016-05-19 07:11:50 +02:00
extends 'Lemonldap::NG::Portal::Auth::_WebForm',
'Lemonldap::NG::Portal::Lib::DBI';
2017-01-25 12:51:30 +01:00
# INTIALIZATION
sub init {
my ($self) = @_;
foreach (qw(dbiAuthTable dbiAuthLoginCol dbiAuthPasswordCol)) {
2020-04-21 22:09:40 +02:00
$self->logger->warn( ref($self) . " seems not configured: missing $_" )
unless $self->conf->{$_};
}
2017-01-25 12:51:30 +01:00
return ( $self->Lemonldap::NG::Portal::Auth::_WebForm::init
and $self->Lemonldap::NG::Portal::Lib::DBI::init );
}
has authnLevel => (
is => 'rw',
lazy => 1,
default => sub {
$_[0]->conf->{dbiAuthnLevel};
}
);
2016-06-09 20:40:20 +02:00
# RUNNING METHODS
2016-05-19 07:11:50 +02:00
sub authenticate {
my ( $self, $req ) = @_;
if ( $self->check_password($req) ) {
return PE_OK;
}
else {
$self->setSecurity($req);
return PE_BADCREDENTIALS;
}
2016-05-19 07:11:50 +02:00
}
sub authLogout {
2021-02-01 22:30:37 +01:00
return PE_OK;
2016-05-19 07:11:50 +02:00
}
1;