X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FAdmin.pm;h=06fd3cfe3c2991b42f831ddadf2788aef57ec1c6;hb=844a541e0d8f59644540413f675e8f07cd154cf6;hp=2e41ee90e53d3a87b3d9bf7e915549fb1ab9a8c6;hpb=075bd42af8885aee3c18fe055a2c82b8b43f4cea;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index 2e41ee90e..06fd3cfe3 100644 --- a/SL/Dispatcher/AuthHandler/Admin.pm +++ b/SL/Dispatcher/AuthHandler/Admin.pm @@ -6,16 +6,28 @@ use parent qw(Rose::Object); use SL::Layout::Dispatcher; sub handle { - %::myconfig = (); + my ($self, %params) = @_; - 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()); + %::myconfig = User->get_default_myconfig; - $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin'); + 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'); $::auth->delete_session_value('admin_password'); + $::auth->punish_wrong_login; SL::Dispatcher::show_error('admin/adminlogin', 'password'); + + return 0; } 1;