X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FAdmin.pm;h=06fd3cfe3c2991b42f831ddadf2788aef57ec1c6;hb=97e26b6903f9049ecbaec55266bad5e362de4408;hp=07778b6dbd6523e82aab9105b1c8527da122b40f;hpb=a3339fc75fd7c2fd1328e5444dcde255e4034f95;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index 07778b6db..06fd3cfe3 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -1,17 +1,33 @@ package SL::Dispatcher::AuthHandler::Admin; use strict; - use parent qw(Rose::Object); +use SL::Layout::Dispatcher; + sub handle { - %::myconfig = (); + my ($self, %params) = @_; + + %::myconfig = User->get_default_myconfig; - return if $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); - return if !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK()); + my $ok = $::auth->is_api_token_cookie_valid; + $ok ||= $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); + $ok ||= !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK()); + $ok ||= $params{action} eq 'login'; + $::auth->create_or_refresh_session; + + if ($ok) { + $::auth->delete_session_value('FLASH'); + return 1; + } + + $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); $::auth->delete_session_value('admin_password'); - SL::Dispatcher::show_error('login/password_error', 'password', is_admin => 1); + $::auth->punish_wrong_login; + SL::Dispatcher::show_error('admin/adminlogin', 'password'); + + return 0; } 1;