From: Marius Gavrilescu Date: Sun, 29 Mar 2015 20:08:17 +0000 (+0300) Subject: Cache remote_user per-request X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=2a06b02c103bb9dd8783232af05f1a12a6f26862;hp=c5343878b97ee6723193c22a1e106eaa5f3b0fba;p=gruntmaster-page.git Cache remote_user per-request --- 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} }