X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FAdmin.pm;h=06fd3cfe3c2991b42f831ddadf2788aef57ec1c6;hb=cce0311c1dfbe57e0fbd6082284d8360a9c54239;hp=baacc67e357556f6c4ce9f5cac265f8a6722ec7a;hpb=d8ac08282dad52789b8bea785e8cddae44085483;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index baacc67e3..06fd3cfe3 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -8,17 +8,23 @@ use SL::Layout::Dispatcher; sub handle { my ($self, %params) = @_; - %::myconfig = (); + %::myconfig = User->get_default_myconfig; - return 1 if $::auth->get_api_token_cookie; - return 1 if $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'}) == $::auth->OK()); - return 1 if !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK()); - return 1 if $params{action} eq 'login'; + 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'; - $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); + $::auth->create_or_refresh_session; - $::auth->punish_wrong_login; + if ($ok) { + $::auth->delete_session_value('FLASH'); + return 1; + } + + $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); $::auth->delete_session_value('admin_password'); + $::auth->punish_wrong_login; SL::Dispatcher::show_error('admin/adminlogin', 'password'); return 0;