X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FUser.pm;h=5ee543beb921752805d59d0afc5ccb490ccad6a0;hb=a4c3e9de7b3169ac6a0ad270022da9aeed91f9ff;hp=13d64486379f462b0aeb46c6f6ecc22d17cea9e9;hpb=6afd06adfeb66b481b7240637351a34a41e702d1;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/User.pm b/SL/Dispatcher/AuthHandler/User.pm index 13d644863..5ee543beb 100644 --- a/SL/Dispatcher/AuthHandler/User.pm +++ b/SL/Dispatcher/AuthHandler/User.pm @@ -1,24 +1,44 @@ package SL::Dispatcher::AuthHandler::User; use strict; - use parent qw(Rose::Object); +use SL::Layout::Dispatcher; + sub handle { - my $login = $::auth->get_session_value('login'); - SL::Dispatcher::show_error('login/password_error', 'password') if not defined $login; + my ($self, %param) = @_; + + my $login = $::form->{'{AUTH}login'} || $::auth->get_session_value('login'); + return $self->_error(%param) if !defined $login; + + my $client_id = $::form->{'{AUTH}client_id'} || $::auth->get_session_value('client_id'); + return $self->_error(%param) if !$client_id || !$::auth->set_client($client_id); %::myconfig = $::auth->read_user(login => $login); - SL::Dispatcher::show_error('login/password_error', 'password') unless $::myconfig{login}; + return $self->_error(%param) unless $::myconfig{login}; $::locale = Locale->new($::myconfig{countrycode}); + $::request->{layout} = SL::Layout::Dispatcher->new(style => $::myconfig{menustyle}); + + my $ok = $::auth->get_api_token_cookie ? 1 : 0; + $ok ||= $::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, $::form->{'{AUTH}password'})); + $ok ||= !$::form->{'{AUTH}login'} && (SL::Auth::OK() == $::auth->authenticate($::myconfig{login}, undef)); - SL::Dispatcher::show_error('login/password_error', 'password') if SL::Auth::OK != $::auth->authenticate($login, undef); + return $self->_error(%param) if !$ok; $::auth->create_or_refresh_session; $::auth->delete_session_value('FLASH'); - delete $::form->{password}; + + return 1; +} + +sub _error { + my $self = shift; + + $::auth->punish_wrong_login; + print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login&error=password'); + return 0; } 1;