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

49 lines
936 B
Perl
Raw Normal View History

2016-03-30 07:47:38 +02:00
##@file
# Demo authentication backend file
##@class
# Demo authentication backend class
package Lemonldap::NG::Portal::Auth::Demo;
use strict;
use Mouse;
2016-05-22 14:22:59 +02:00
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_BADCREDENTIALS);
2016-03-30 07:47:38 +02:00
extends qw(Lemonldap::NG::Portal::Auth::_WebForm);
our $VERSION = '2.0.9';
2016-03-30 07:47:38 +02:00
2016-06-09 20:40:20 +02:00
# INITIALIZATION
2016-03-30 07:47:38 +02:00
# Initialize demo accounts
# @return Lemonldap::NG::Portal constant
sub init {
my $self = shift;
# Add warning in log
2017-02-15 07:41:50 +01:00
$self->logger->warn(
"Using demonstration mode, go to Manager to edit the configuration");
2016-03-30 07:47:38 +02:00
2017-01-25 12:51:30 +01:00
return $self->Lemonldap::NG::Portal::Auth::_WebForm::init();
2016-03-30 07:47:38 +02:00
}
2016-06-09 20:40:20 +02:00
# RUNNING METHODS
2016-03-30 07:47:38 +02:00
sub authenticate {
2016-04-29 09:27:26 +02:00
my ( $self, $req ) = @_;
2016-03-30 07:47:38 +02:00
unless ( $req->{user} eq $req->data->{password} ) {
$self->userLogger->warn("Bad password for $req->{user}");
$self->setSecurity($req);
return PE_BADCREDENTIALS;
}
2016-03-30 07:47:38 +02:00
PE_OK;
}
sub authLogout {
PE_OK;
}
1;