use constant SESSION_KEY_ROOT_AUTH => 'session_auth_status_root';
use constant SESSION_KEY_USER_AUTH => 'session_auth_status_user';
+use Rose::Object::MakeMethods::Generic (
+ scalar => [ qw(client) ],
+);
+
+
sub new {
$main::lxdebug->enter_sub();
$self->{unique_counter} = 0;
$self->{column_information} = SL::Auth::ColumnInformation->new(auth => $self);
$self->{authenticator}->reset;
+
+ $self->client(undef);
+}
+
+sub set_client {
+ my ($self, $id_or_name) = @_;
+
+ $self->client(undef);
+
+ my $column = $id_or_name =~ m/^\d+$/ ? 'id' : 'name';
+ my $dbh = $self->dbconnect;
+
+ return undef unless $dbh;
+
+ $self->client($dbh->selectrow_hashref(qq|SELECT * FROM auth.clients WHERE ${column} = ?|, undef, $id_or_name));
+
+ return $self->client;
}
sub get_user_dbh {
if (!$session_id) {
$main::lxdebug->leave_sub();
- return SESSION_NONE;
+ return $self->session_restore_result(SESSION_NONE());
}
my ($dbh, $query, $sth, $cookie, $ref, $form);
# Don't fail if the auth DB doesn't yet.
if (!( $dbh = $self->dbconnect(1) )) {
$::lxdebug->leave_sub;
- return SESSION_NONE;
+ return $self->session_restore_result(SESSION_NONE());
}
# Don't fail if the "auth" schema doesn't exist yet, e.g. if the
if (!($sth = $dbh->prepare($query)) || !$sth->execute($session_id)) {
$sth->finish if $sth;
$::lxdebug->leave_sub;
- return SESSION_NONE;
+ return $self->session_restore_result(SESSION_NONE());
}
$cookie = $sth->fetchrow_hashref;
if ($cookie_is_bad) {
$self->destroy_session();
$main::lxdebug->leave_sub();
- return $cookie ? SESSION_EXPIRED : SESSION_NONE;
+ return $self->session_restore_result($cookie ? SESSION_EXPIRED() : SESSION_NONE());
}
if ($self->{column_information}->has('auto_restore')) {
$main::lxdebug->leave_sub();
- return SESSION_OK;
+ return $self->session_restore_result(SESSION_OK());
+}
+
+sub session_restore_result {
+ my $self = shift;
+ if (@_) {
+ $self->{session_restore_result} = $_[0];
+ }
+ return $self->{session_restore_result};
}
sub _load_without_auto_restore_column {
$main::lxdebug->leave_sub();
}
+sub active_session_ids {
+ my $self = shift;
+ my $dbh = $self->dbconnect;
+
+ my $query = qq|SELECT id FROM auth.session|;
+
+ my @ids = selectall_array_query($::form, $dbh, $query);
+
+ return @ids;
+}
+
sub expire_sessions {
$main::lxdebug->enter_sub();
["email_bcc", $locale->text("May set the BCC field when sending emails")],
["config", $locale->text("Change kivitendo installation settings (all menu entries beneath 'System')")],
["admin", $locale->text("Administration (Used to access instance administration from user logins)")],
+ ["productivity", $locale->text("Productivity")],
+ ["display_admin_link", $locale->text("Show administration link")],
);
return @all_rights;