X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher%2FAuthHandler%2FAdmin.pm;h=ad7c1f413511eead7ac8366b4652941ce6449b20;hb=a4c3e9de7b3169ac6a0ad270022da9aeed91f9ff;hp=77202e8e40ac31183b5b802aee9ee5b6a934869f;hpb=469ca9fc3cac624073270fc3217766dbb7aba253;p=kivitendo-erp.git diff --git a/SL/Dispatcher/AuthHandler/Admin.pm b/SL/Dispatcher/AuthHandler/Admin.pm index 77202e8e4..ad7c1f413 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->get_api_token_cookie ? 1 : 0; + $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;