Automatische Authentifizierung bestehender Sessions über Session-ID + API-Token
[kivitendo-erp.git] / SL / Dispatcher / AuthHandler / Admin.pm
1 package SL::Dispatcher::AuthHandler::Admin;
2
3 use strict;
4 use parent qw(Rose::Object);
5
6 use SL::Layout::Dispatcher;
7
8 sub handle {
9   %::myconfig = ();
10
11   return 1 if  $::auth->get_api_token_cookie;
12   return 1 if  $::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::form->{'{AUTH}admin_password'})            == $::auth->OK());
13   return 1 if !$::form->{'{AUTH}admin_password'} && ($::auth->authenticate_root($::auth->get_session_value('admin_password')) == $::auth->OK());
14
15   $::request->{layout} = SL::Layout::Dispatcher->new(style => 'admin');
16
17   $::auth->punish_wrong_login;
18   $::auth->delete_session_value('admin_password');
19   SL::Dispatcher::show_error('admin/adminlogin', 'password');
20
21   return 0;
22 }
23
24 1;