X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FUser.pm;h=1273d679fa2aee8ebb34e7310715565a2cf45d71;hb=98ccfccb26e831dd0a12dcae229eabb33744ed8b;hp=13d64486379f462b0aeb46c6f6ecc22d17cea9e9;hpb=6afd06adfeb66b481b7240637351a34a41e702d1;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/User.pm b/SL/Dispatcher/AuthHandler/User.pm index 13d644863..1273d679f 100644 --- a/SL/Dispatcher/AuthHandler/User.pm +++ b/SL/Dispatcher/AuthHandler/User.pm @@ -1,24 +1,39 @@ 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'); + $self->_error(%param) if !defined $login; %::myconfig = $::auth->read_user(login => $login); - SL::Dispatcher::show_error('login/password_error', 'password') unless $::myconfig{login}; + $self->_error(%param) unless $::myconfig{login}; $::locale = Locale->new($::myconfig{countrycode}); + $::request->{layout} = SL::Layout::Dispatcher->new(style => $::myconfig{menustyle}); + + my $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); + $self->_error(%param) if !$ok; $::auth->create_or_refresh_session; $::auth->delete_session_value('FLASH'); - delete $::form->{password}; + + return %::myconfig; +} + +sub _error { + my $self = shift; + + $::auth->punish_wrong_login; + print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login&error=password'); } 1;