From 3e29b95e9880aad25d13f4f410fda4ee1f1c5e9d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 6 Jun 2013 13:21:47 +0200 Subject: [PATCH] =?utf8?q?SL::Auth:=20Client-Properties=20aus=20Auth-DB=20?= =?utf8?q?lesen=20und=20in=20$::auth->client=20speichern=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Auth.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/SL/Auth.pm b/SL/Auth.pm index 420724b4c..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 { -- 2.20.1