Merge pull request #8091 from cirosantilli/factor-ability-abilities
Factor abilities methods
This commit is contained in:
commit
beabf5db8c
|
@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
|
|||
before_filter :authenticate_user!
|
||||
before_filter :reject_blocked!
|
||||
before_filter :check_password_expiration
|
||||
before_filter :add_abilities
|
||||
before_filter :ldap_security_check
|
||||
before_filter :default_headers
|
||||
before_filter :add_gon_variables
|
||||
|
@ -72,7 +71,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def abilities
|
||||
@abilities ||= Six.new
|
||||
Ability.abilities
|
||||
end
|
||||
|
||||
def can?(object, action, subject)
|
||||
|
@ -113,10 +112,6 @@ class ApplicationController < ActionController::Base
|
|||
nil
|
||||
end
|
||||
|
||||
def add_abilities
|
||||
abilities << Ability
|
||||
end
|
||||
|
||||
def authorize_project!(action)
|
||||
return access_denied! unless can?(current_user, action, project)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Explore::GroupsController < ApplicationController
|
||||
skip_before_filter :authenticate_user!,
|
||||
:reject_blocked, :set_current_user_for_observers,
|
||||
:add_abilities
|
||||
:reject_blocked, :set_current_user_for_observers
|
||||
|
||||
layout "explore"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Explore::ProjectsController < ApplicationController
|
||||
skip_before_filter :authenticate_user!,
|
||||
:reject_blocked,
|
||||
:add_abilities
|
||||
:reject_blocked
|
||||
|
||||
layout 'explore'
|
||||
|
||||
|
|
|
@ -262,5 +262,13 @@ class Ability
|
|||
end
|
||||
rules
|
||||
end
|
||||
|
||||
def abilities
|
||||
@abilities ||= begin
|
||||
abilities = Six.new
|
||||
abilities << self
|
||||
abilities
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -330,11 +330,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def abilities
|
||||
@abilities ||= begin
|
||||
abilities = Six.new
|
||||
abilities << Ability
|
||||
abilities
|
||||
end
|
||||
Ability.abilities
|
||||
end
|
||||
|
||||
def can_select_namespace?
|
||||
|
|
|
@ -6,11 +6,7 @@ class BaseService
|
|||
end
|
||||
|
||||
def abilities
|
||||
@abilities ||= begin
|
||||
abilities = Six.new
|
||||
abilities << Ability
|
||||
abilities
|
||||
end
|
||||
Ability.abilities
|
||||
end
|
||||
|
||||
def can?(object, action, subject)
|
||||
|
|
Loading…
Reference in New Issue