use SL::Auth::LDAP;
use SL::User;
+use SL::DBUpgrade2;
use SL::DBUtils;
use strict;
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);
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();
$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};
}
$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';
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();
}
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();