]> iEval git - gruntmaster-page.git/commitdiff
Cache remote_user per-request
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 29 Mar 2015 20:08:17 +0000 (23:08 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 12 Aug 2015 15:15:13 +0000 (18:15 +0300)
lib/Plack/App/Gruntmaster.pm

index 1af76d0c14072c2696922b3d892e9034fc636df6..d48166ef714a24ba4353221687ba1ec8f7e78bc9 100644 (file)
@@ -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} }
This page took 0.033934 seconds and 4 git commands to generate.