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 my $client_id = $::form->{'{AUTH}client_id'} || $::auth->get_session_value('client_id');
15 return $self->_error(%param) if !$client_id || !$::auth->set_client($client_id);
17 %::myconfig = User->get_default_myconfig($::auth->read_user(login => $login));
19 return $self->_error(%param) unless $::myconfig{login};
21 $::locale = Locale->new($::myconfig{countrycode});
22 $::request->{layout} = SL::Layout::Dispatcher->new(style => $::myconfig{menustyle});
24 my $ok = $::auth->is_api_token_cookie_valid;
25 $ok ||= $::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, $::form->{'{AUTH}password'}));
26 $ok ||= !$::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, undef));
28 return $self->_error(%param) if !$ok;
30 $::auth->create_or_refresh_session;
31 $::auth->delete_session_value('FLASH');
32 $::instance_conf->reload->data;
40 $::auth->punish_wrong_login;
42 require SL::Controller::Base;
43 SL::Controller::Base->new->redirect_to('controller.pl?action=LoginScreen/user_login&error=password');