Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b66a1527
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b66a1527
编写于
10月 19, 2014
作者:
C
Ciro Santilli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Factor abilities methods
in app controller, user model and services.
上级
3880bb61
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
13 addition
and
20 deletion
+13
-20
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-6
app/controllers/explore/groups_controller.rb
app/controllers/explore/groups_controller.rb
+1
-2
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+1
-2
app/models/ability.rb
app/models/ability.rb
+8
-0
app/models/user.rb
app/models/user.rb
+1
-5
app/services/base_service.rb
app/services/base_service.rb
+1
-5
未找到文件。
app/controllers/application_controller.rb
浏览文件 @
b66a1527
...
@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
...
@@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
before_filter
:authenticate_user!
before_filter
:authenticate_user!
before_filter
:reject_blocked!
before_filter
:reject_blocked!
before_filter
:check_password_expiration
before_filter
:check_password_expiration
before_filter
:add_abilities
before_filter
:ldap_security_check
before_filter
:ldap_security_check
before_filter
:dev_tools
if
Rails
.
env
==
'development'
before_filter
:dev_tools
if
Rails
.
env
==
'development'
before_filter
:default_headers
before_filter
:default_headers
...
@@ -73,7 +72,7 @@ class ApplicationController < ActionController::Base
...
@@ -73,7 +72,7 @@ class ApplicationController < ActionController::Base
end
end
def
abilities
def
abilities
@abilities
||=
Six
.
new
Ability
.
abilities
end
end
def
can?
(
object
,
action
,
subject
)
def
can?
(
object
,
action
,
subject
)
...
@@ -111,10 +110,6 @@ class ApplicationController < ActionController::Base
...
@@ -111,10 +110,6 @@ class ApplicationController < ActionController::Base
nil
nil
end
end
def
add_abilities
abilities
<<
Ability
end
def
authorize_project!
(
action
)
def
authorize_project!
(
action
)
return
access_denied!
unless
can?
(
current_user
,
action
,
project
)
return
access_denied!
unless
can?
(
current_user
,
action
,
project
)
end
end
...
...
app/controllers/explore/groups_controller.rb
浏览文件 @
b66a1527
class
Explore::GroupsController
<
ApplicationController
class
Explore::GroupsController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
skip_before_filter
:authenticate_user!
,
:reject_blocked
,
:set_current_user_for_observers
,
:reject_blocked
,
:set_current_user_for_observers
:add_abilities
layout
"explore"
layout
"explore"
...
...
app/controllers/explore/projects_controller.rb
浏览文件 @
b66a1527
class
Explore::ProjectsController
<
ApplicationController
class
Explore::ProjectsController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
skip_before_filter
:authenticate_user!
,
:reject_blocked
,
:reject_blocked
:add_abilities
layout
'explore'
layout
'explore'
...
...
app/models/ability.rb
浏览文件 @
b66a1527
...
@@ -262,5 +262,13 @@ class Ability
...
@@ -262,5 +262,13 @@ class Ability
end
end
rules
rules
end
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
self
abilities
end
end
end
end
end
end
app/models/user.rb
浏览文件 @
b66a1527
...
@@ -330,11 +330,7 @@ class User < ActiveRecord::Base
...
@@ -330,11 +330,7 @@ class User < ActiveRecord::Base
end
end
def
abilities
def
abilities
@abilities
||=
begin
Ability
.
abilities
abilities
=
Six
.
new
abilities
<<
Ability
abilities
end
end
end
def
can_select_namespace?
def
can_select_namespace?
...
...
app/services/base_service.rb
浏览文件 @
b66a1527
...
@@ -6,11 +6,7 @@ class BaseService
...
@@ -6,11 +6,7 @@ class BaseService
end
end
def
abilities
def
abilities
@abilities
||=
begin
Ability
.
abilities
abilities
=
Six
.
new
abilities
<<
Ability
abilities
end
end
end
def
can?
(
object
,
action
,
subject
)
def
can?
(
object
,
action
,
subject
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录