X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9ae27aaed7df10d51373d5ddf94d8479ade1071d..dfa7a3a99a0b1ba731d1d4f81768308c10ace0d3:/SL/Auth.pm diff --git a/SL/Auth.pm b/SL/Auth.pm index 120288755..3b7a6287f 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -13,6 +13,7 @@ use SL::Auth::DB; use SL::Auth::LDAP; use SL::User; +use SL::DBUpgrade2; use SL::DBUtils; use strict; @@ -77,27 +78,11 @@ sub mini_error { sub _read_auth_config { $main::lxdebug->enter_sub(); - my $self = shift; - - my $code; - my $in = IO::File->new('config/authentication.pl', 'r'); - - if (!$in) { - my $locale = Locale->new('en'); - $self->mini_error($locale->text('The config file "config/authentication.pl" was not found.')); - } - - while (<$in>) { - $code .= $_; - } - $in->close(); - - eval $code; + my $self = shift; - if ($@) { - my $locale = Locale->new('en'); - $self->mini_error($locale->text('The config file "config/authentication.pl" contained invalid Perl code:'), $@); - } + map { $self->{$_} = $::lx_office_conf{authentication}->{$_} } keys %{ $::lx_office_conf{authentication} }; + $self->{DB_config} = $::lx_office_conf{'authentication/database'}; + $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; if ($self->{module} eq 'DB') { $self->{authenticator} = SL::Auth::DB->new($self); @@ -108,19 +93,19 @@ sub _read_auth_config { if (!$self->{authenticator}) { my $locale = Locale->new('en'); - $self->mini_error($locale->text('No or an unknown authenticantion module specified in "config/authentication.pl".')); + $self->mini_error($locale->text('No or an unknown authenticantion module specified in "config/lx_office.conf".')); } my $cfg = $self->{DB_config}; if (!$cfg) { my $locale = Locale->new('en'); - $self->mini_error($locale->text('config/authentication.pl: Key "DB_config" is missing.')); + $self->mini_error($locale->text('config/lx_office.conf: Key "DB_config" is missing.')); } if (!$cfg->{host} || !$cfg->{db} || !$cfg->{user}) { my $locale = Locale->new('en'); - $self->mini_error($locale->text('config/authentication.pl: Missing parameters in "DB_config". Required parameters are "host", "db" and "user".')); + $self->mini_error($locale->text('config/lx_office.conf: Missing parameters in "authentication/database". Required parameters are "host", "db" and "user".')); } $self->{authenticator}->verify_config(); @@ -187,7 +172,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 +241,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 +284,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,16 +474,15 @@ 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 = ?|; $sth = prepare_execute_query($form, $dbh, $query, $session_id); while (my $ref = $sth->fetchrow_hashref()) { - my $value = $self->_load_value($ref->{sess_value}); - $self->{SESSION}->{$ref->{sess_key}} = $value; - $form->{$ref->{sess_key}} = $value if (!defined $form->{$ref->{sess_key}}); + $self->{SESSION}->{$ref->{sess_key}} = $ref->{sess_value}; + $form->{$ref->{sess_key}} = $self->_load_value($ref->{sess_value}) if (!defined $form->{$ref->{sess_key}}); } $sth->finish();