%::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->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';
- $::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;