You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/12/29 23:57:37 UTC

[whimsy] branch master updated: Simplify auth checks

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new cc61b5f  Simplify auth checks
cc61b5f is described below

commit cc61b5f1f9cbfbc0768ee5f60f168bcc5b70e9dc
Author: Sebb <se...@apache.org>
AuthorDate: Tue Dec 29 23:51:59 2020 +0000

    Simplify auth checks
---
 www/roster/models/committer.rb | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb
index 3f75264..b6f7e07 100644
--- a/www/roster/models/committer.rb
+++ b/www/roster/models/committer.rb
@@ -24,10 +24,13 @@ class Committer
 
     name = {}
 
+    auth = Auth.info(env)
+    isSelfOrMember = (id == env.user or auth[:member])
+
     if person.icla
       name[:public_name] = person.public_name
 
-      if id == env.user or ASF::Person.find(env.user).asf_member?
+      if isSelfOrMember
         name[:legal_name] = person.icla.legal_name
       end
     end
@@ -126,9 +129,9 @@ class Committer
 
     response[:forms] = {}
 
-    if ASF::Person.find(env.user).asf_member? # i.e. member karma
+    if auth[:member] # i.e. member karma
 
-      if person.icla and person.icla.claRef # Not all people have iclas
+      if person.icla and person.icla.claRef # Not all people have iclas (only check if secretary role)
         file = ASF::ICLAFiles.match_claRef(person.icla.claRef)
         if file
           url =ASF::SVN.svnurl('iclas')
@@ -184,14 +187,13 @@ class Committer
 
     response[:member] = member unless member.empty?
 
-    if ASF::Person.find(env.user).asf_member? or env.user == id
+    if isSelfOrMember
       response[:moderates] = {}
 
       require 'whimsy/asf/mlist'
       ASF::MLIST.moderates(person.all_mail, response)
     end
 
-    auth = Auth.info(env)
     if env.user == id or auth[:root] or auth[:secretary]
       require 'whimsy/asf/mlist'
       ASF::MLIST.subscriptions(person.all_mail, response) # updates response[:subscriptions]