Merge branch 'master' of git@lx-office.linet-services.de:lx-office-erp
[kivitendo-erp.git] / SL / Auth.pm
index 5cedbec..f2d15a8 100644 (file)
@@ -13,6 +13,7 @@ use SL::Auth::DB;
 use SL::Auth::LDAP;
 
 use SL::User;
+use SL::DBUpgrade2;
 use SL::DBUtils;
 
 use strict;
@@ -187,7 +188,7 @@ sub dbconnect {
     $main::form->error($main::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr);
   }
 
-  $main::lxdebug->leave_sub();
+  $main::lxdebug->leave_sub(2);
 
   return $self->{dbh};
 }
@@ -256,7 +257,7 @@ sub create_database {
 
   $main::lxdebug->message(LXDebug->DEBUG1(), "Auth::create_database DSN: $dsn");
 
-  my $charset    = $main::dbcharset;
+  my $charset    = $::lx_office_conf{system}->{dbcharset};
   $charset     ||= Common::DEFAULT_CHARSET;
   my $encoding   = $Common::charset_to_db_encoding{$charset};
   $encoding    ||= 'UNICODE';
@@ -299,11 +300,11 @@ sub create_tables {
   my $self = shift;
   my $dbh  = $self->dbconnect();
 
-  my $charset    = $main::dbcharset;
+  my $charset    = $::lx_office_conf{system}->{dbcharset};
   $charset     ||= Common::DEFAULT_CHARSET;
 
   $dbh->rollback();
-  User->process_query($main::form, $dbh, 'sql/auth_db.sql', undef, $charset);
+  SL::DBUpgrade2->new(form => $::form)->process_query($dbh, 'sql/auth_db.sql', undef, $charset);
 
   $main::lxdebug->leave_sub();
 }
@@ -489,7 +490,7 @@ sub restore_session {
   if (!$cookie || $cookie->{is_expired} || ($cookie->{ip_address} ne $ENV{REMOTE_ADDR})) {
     $self->destroy_session();
     $main::lxdebug->leave_sub();
-    return SESSION_EXPIRED;
+    return $cookie ? SESSION_EXPIRED : SESSION_NONE;
   }
 
   $query = qq|SELECT sess_key, sess_value FROM auth.session_content WHERE session_id = ?|;