From 2a06b02c103bb9dd8783232af05f1a12a6f26862 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 29 Mar 2015 23:08:17 +0300 Subject: [PATCH 1/1] Cache remote_user per-request --- lib/Plack/App/Gruntmaster.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index 1af76d0..d48166e 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -44,9 +44,12 @@ my ($env, $privacy); sub db { $env->{'gruntmaster.dbic'} } sub remote_user { - my $user = $env->{REMOTE_USER}; - $user &&= db->user_entry($user); - $user + unless ($env->{'gruntmaster.user'}) { + my $user = $env->{REMOTE_USER}; + $user &&= db->user_entry($user); + $env->{'gruntmaster.user'} = $user; + } + $env->{'gruntmaster.user'} } sub admin { remote_user && remote_user->{admin} } -- 2.39.2