X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FAdmin.pm;h=ebb4a4d3f9ec469fc1dd31df9cb5c9464bec7f83;hb=8abdaf4026ee63628e524146ded609df44fc92af;hp=77202e8e40ac31183b5b802aee9ee5b6a934869f;hpb=540c0b5e9a38158e6f7a6efacd20b2477efad7ac;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index 77202e8e4..ebb4a4d3f 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -1,18 +1,34 @@ package SL::Dispatcher::AuthHandler::Admin; use strict; - use parent qw(Rose::Object); +use SL::Layout::Dispatcher; + sub handle { + my ($self, %params) = @_; + %::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->punish_wrong_login; + $::auth->create_or_refresh_session; + + if ($ok) { + $::auth->delete_session_value('FLASH'); + return 1; + } + + $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); + $::request->layout->no_menu(1); $::auth->delete_session_value('admin_password'); + $::auth->punish_wrong_login; SL::Dispatcher::show_error('admin/adminlogin', 'password'); + + return 0; } 1;