1 package SL::Dispatcher::AuthHandler::User;
4 use parent qw(Rose::Object);
6 use SL::Layout::Dispatcher;
9 my ($self, %param) = @_;
11 my $login = $::form->{'{AUTH}login'} || $::auth->get_session_value('login');
12 return $self->_error(%param) if !defined $login;
14 %::myconfig = $::auth->read_user(login => $login);
16 return $self->_error(%param) unless $::myconfig{login};
18 $::locale = Locale->new($::myconfig{countrycode});
19 $::request->{layout} = SL::Layout::Dispatcher->new(style => $::myconfig{menustyle});
21 my $ok = $::auth->get_api_token_cookie ? 1 : 0;
22 $ok ||= $::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, $::form->{'{AUTH}password'}));
23 $ok ||= !$::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, undef));
25 return $self->_error(%param) if !$ok;
27 $::auth->create_or_refresh_session;
28 $::auth->delete_session_value('FLASH');
36 $::auth->punish_wrong_login;
37 print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login&error=password');