-  if (!$::auth->session_tables_present) {
-    if ($::form->{script} eq 'admin.pl') {
-      ::run();
-      ::end_of_request();
-    } else {
-      show_error('login/auth_db_unreachable');
+  my (%params) = @_;
+
+  _check_for_old_config_files();
+
+  if (!$::auth->session_tables_present && !is_admin_request(%params)) {
+    show_error('login_screen/auth_db_unreachable');
+  }
+
+  if ($::request->type !~ m/^ (?: html | js | json ) $/x) {
+    die $::locale->text("Invalid request type '#1'", $::request->type);
+  }
+}
+
+sub pre_request_initialization {
+  my ($self, %params) = @_;
+
+  $self->unrequire_bin_mozilla;
+
+  $::locale        = Locale->new($::lx_office_conf{system}->{language});
+  $::form          = Form->new;
+  $::instance_conf = SL::InstanceConfiguration->new;
+  $::request       = SL::Request->new(
+    cgi            => CGI->new({}),
+    layout         => SL::Layout::None->new,
+  );
+
+  my $session_result = $::auth->restore_session;
+  $::auth->create_or_refresh_session;
+
+  if ($params{client}) {
+    $::auth->set_client($params{client}) || die("cannot find client " . $params{client});
+
+    if ($params{login}) {
+      die "cannot find user " . $params{login}            unless %::myconfig = $::auth->read_user(login => $params{login});
+      die "cannot find locale for user " . $params{login} unless $::locale   = Locale->new($::myconfig{countrycode});
+
+      $::form->{login} = $params{login}; # normaly implicit at login