BigW Consortium Gitlab

Commit 08dc3822 by Robert Speicher

Rename `not_auth_*` ability methods to `anonymous_*`

parent 1b347565
class Ability class Ability
class << self class << self
def allowed(user, subject) def allowed(user, subject)
return not_auth_abilities(user, subject) if user.nil? return anonymous_abilities(user, subject) if user.nil?
return [] unless user.is_a?(User) return [] unless user.is_a?(User)
return [] if user.blocked? return [] if user.blocked?
...@@ -19,22 +19,21 @@ class Ability ...@@ -19,22 +19,21 @@ class Ability
end.concat(global_abilities(user)) end.concat(global_abilities(user))
end end
# List of possible abilities # List of possible abilities for anonymous user
# for non-authenticated user def anonymous_abilities(user, subject)
def not_auth_abilities(user, subject)
case true case true
when subject.is_a?(PersonalSnippet) when subject.is_a?(PersonalSnippet)
not_auth_personal_snippet_abilities(subject) anonymous_personal_snippet_abilities(subject)
when subject.is_a?(Project) || subject.respond_to?(:project) when subject.is_a?(Project) || subject.respond_to?(:project)
not_auth_project_abilities(subject) anonymous_project_abilities(subject)
when subject.is_a?(Group) || subject.respond_to?(:group) when subject.is_a?(Group) || subject.respond_to?(:group)
not_auth_group_abilities(subject) anonymous_group_abilities(subject)
else else
[] []
end end
end end
def not_auth_project_abilities(subject) def anonymous_project_abilities(subject)
project = if subject.is_a?(Project) project = if subject.is_a?(Project)
subject subject
else else
...@@ -62,7 +61,7 @@ class Ability ...@@ -62,7 +61,7 @@ class Ability
end end
end end
def not_auth_group_abilities(subject) def anonymous_group_abilities(subject)
group = if subject.is_a?(Group) group = if subject.is_a?(Group)
subject subject
else else
...@@ -76,7 +75,7 @@ class Ability ...@@ -76,7 +75,7 @@ class Ability
end end
end end
def not_auth_personal_snippet_abilities(snippet) def anonymous_personal_snippet_abilities(snippet)
if snippet.public? if snippet.public?
[:read_personal_snippet] [:read_personal_snippet]
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment