X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDispatcher.pm;h=fe992ed2aef58c2e9b20b96a4ef3e193d7b3dc13;hb=13b7b660f564981597f58ba4e6d0b4cc5b7c6d1a;hp=8329c5b75abb0406b141582968514f96e108d0a9;hpb=66c08b6472a2467444192dbfed35e9f30f7c910d;p=kivitendo-erp.git diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index 8329c5b75..fe992ed2a 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -223,7 +223,7 @@ sub handle_request { $::form->{action} =~ s/( |-|,|\#)/_/g; ($script, $path, $suffix) = fileparse($script_name, ".pl"); - require_main_code($script, $suffix); + require_main_code($script, $suffix) unless $script eq 'admin'; $::form->{script} = $script . $suffix; @@ -248,41 +248,33 @@ sub handle_request { _require_controller('LoginScreen'); } - if (($script eq 'login') && !$action) { - print $::request->{cgi}->redirect('controller.pl?action=LoginScreen/user_login'); + if ( (($script eq 'login') && !$action) + || ($script eq 'admin') + || (SL::Auth::SESSION_EXPIRED() == $session_result)) { + $self->redirect_to_login($script); - } elsif ($script eq 'admin') { - ::run($session_result); - - } else { - $self->redirect_to_login($script) if SL::Auth::SESSION_EXPIRED == $session_result; - - my %auth_result = $self->{auth_handler}->handle( - routing_type => $routing_type, - script => $script, - controller => $script_name, - action => $action, - ); - - ::end_of_request() unless $auth_result{auth_ok}; + } - delete @{ $::form }{ grep { m/^\{AUTH\}/ } keys %{ $::form } } unless $auth_result{keep_auth_vars}; + my %auth_result = $self->{auth_handler}->handle( + routing_type => $routing_type, + script => $script, + controller => $script_name, + action => $action, + ); - if ($action) { - $::instance_conf->init if $auth_result{auth_level} eq 'user'; + ::end_of_request() unless $auth_result{auth_ok}; - map { $::form->{$_} = $::myconfig{$_} } qw(charset) - unless $action eq 'save' && $::form->{type} eq 'preferences'; + delete @{ $::form }{ grep { m/^\{AUTH\}/ } keys %{ $::form } } unless $auth_result{keep_auth_vars}; - $::form->set_standard_title; - if ($routing_type eq 'old') { - ::call_sub('::' . $::locale->findsub($action)); - } else { - _run_controller($script_name, $action); - } + if ($action) { + $::form->set_standard_title; + if ($routing_type eq 'old') { + ::call_sub('::' . $::locale->findsub($action)); } else { - $::form->error($::locale->text('action= not defined!')); + _run_controller($script_name, $action); } + } else { + $::form->error($::locale->text('action= not defined!')); } 1; @@ -358,7 +350,7 @@ sub _route_dispatcher_request { my ($script_name, $action); eval { - die "Unroutable request -- inavlid module name.\n" if !$::form->{M} || ($::form->{M} !~ m/^${name_re}$/); + die "Unroutable request -- invalid module name.\n" if !$::form->{M} || ($::form->{M} !~ m/^${name_re}$/); $script_name = $::form->{M} . '.pl'; if ($::form->{A}) { @@ -366,7 +358,7 @@ sub _route_dispatcher_request { } else { $action = first { m/^A_${name_re}$/ } keys %{ $::form }; - die "Unroutable request -- inavlid action name.\n" if !$action; + die "Unroutable request -- invalid action name.\n" if !$action; delete $::form->{$action}; $action = substr $action, 2; @@ -387,7 +379,7 @@ sub _route_controller_request { my ($controller, $action, $request_type); eval { - $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) / ( [a-z] [a-z0-9_]* ) ( \. [a-zA-Z]+ )? $|x || die "Unroutable request -- inavlid controller/action.\n"; + $::form->{action} =~ m|^ ( [A-Z] [A-Za-z0-9_]* ) / ( [a-z] [a-z0-9_]* ) ( \. [a-zA-Z]+ )? $|x || die "Unroutable request -- invalid controller/action.\n"; ($controller, $action) = ($1, $2); delete $::form->{action};