From c2e1239427e2a7964d8a7f87a06645a1cacaea25 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 26 Nov 2021 17:37:40 +0100 Subject: [PATCH] SL::DB::Employee::auth_user: holt korrespondierendes Objekt aus auth.users Convenience-Funktion, um einfacher an Config-Werte heranzukommen. Beispiel: foreach my $employee (@{ SL::DB::Manager::Employee->get_all }) { my $email = $employee->auth_user->get_config_value('email'); do_stuff_with($email); } --- SL/DB/Employee.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SL/DB/Employee.pm b/SL/DB/Employee.pm index 8da20c0b9..0c321b62f 100644 --- a/SL/DB/Employee.pm +++ b/SL/DB/Employee.pm @@ -27,4 +27,14 @@ sub safe_name { return $self->name || $self->login; } +sub auth_user { + my ($self) = @_; + + die 'not an accessor' if scalar(@_) > 1; + + require SL::DB::AuthUser; + + return SL::DB::Manager::AuthUser->find_by(login => $self->login); +} + 1; -- 2.20.1