X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c497b0352f95a55d204101b70ac771b2dc21ddee..bfe3243c4cdeacea07e53d6365bc384dfd0e6b4d:/SL/Auth.pm diff --git a/SL/Auth.pm b/SL/Auth.pm index d0e8c9ab3..453354d4d 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -26,6 +26,11 @@ use strict; 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(); @@ -51,6 +56,23 @@ sub reset { $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 { @@ -566,7 +588,7 @@ sub restore_session { if (!$session_id) { $main::lxdebug->leave_sub(); - return SESSION_NONE; + return $self->session_restore_result(SESSION_NONE()); } my ($dbh, $query, $sth, $cookie, $ref, $form); @@ -576,7 +598,7 @@ sub restore_session { # 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 @@ -586,7 +608,7 @@ sub restore_session { 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; @@ -605,7 +627,7 @@ sub restore_session { 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')) { @@ -616,7 +638,15 @@ sub restore_session { $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 { @@ -713,6 +743,17 @@ sub destroy_session { $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(); @@ -1049,6 +1090,8 @@ sub all_rights_full { ["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;