X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAuth.pm;h=453354d4d190c6620c010b1ab654a89251c86190;hb=beb61b2e270836ccd11e00ce68ff884cfb7a530d;hp=23a9771e702d1f0e8065542564988ad1d498fb2a;hpb=2accdcbd5f820238b1c09ef2f42823a70041108a;p=kivitendo-erp.git diff --git a/SL/Auth.pm b/SL/Auth.pm index 23a9771e7..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 {