refactor: access controller move to filter.
This commit is contained in:
parent
76db8bd5a6
commit
0ddd259fea
|
@ -35,6 +35,8 @@ class RepositoriesController < ApplicationController
|
||||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||||
before_filter :authorize , :except => [:newrepo,:newcreate,:fork]
|
before_filter :authorize , :except => [:newrepo,:newcreate,:fork]
|
||||||
accept_rss_auth :revisions
|
accept_rss_auth :revisions
|
||||||
|
# hidden repositories filter // 隐藏代码过滤器
|
||||||
|
before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision ]
|
||||||
|
|
||||||
|
|
||||||
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
|
||||||
|
@ -208,12 +210,13 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if !User.current.member_of?(@project)
|
## TODO: the below will move to filter, done.
|
||||||
if @project.hidden_repo
|
# if !User.current.member_of?(@project)
|
||||||
render_403
|
# if @project.hidden_repo
|
||||||
return -1
|
# render_403
|
||||||
end
|
# return -1
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
#if( !User.current.member_of?(@project) || @project.hidden_repo)
|
||||||
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||||||
|
|
||||||
|
@ -458,6 +461,10 @@ class RepositoriesController < ApplicationController
|
||||||
render_error :message => l(:error_scm_not_found), :status => 404
|
render_error :message => l(:error_scm_not_found), :status => 404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_error_forbidden
|
||||||
|
render_error :status => 403
|
||||||
|
end
|
||||||
|
|
||||||
# Handler for Redmine::Scm::Adapters::CommandFailed exception
|
# Handler for Redmine::Scm::Adapters::CommandFailed exception
|
||||||
def show_error_command_failed(exception)
|
def show_error_command_failed(exception)
|
||||||
render_error l(:error_scm_command_failed, exception.message)
|
render_error l(:error_scm_command_failed, exception.message)
|
||||||
|
@ -546,4 +553,12 @@ class RepositoriesController < ApplicationController
|
||||||
)
|
)
|
||||||
graph.burn
|
graph.burn
|
||||||
end
|
end
|
||||||
|
def check_hidden_repo
|
||||||
|
project = Project.find_by_id(params[:id])
|
||||||
|
if !User.current.member_of?(project)
|
||||||
|
if project.hidden_repo
|
||||||
|
render_403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -435,4 +435,13 @@ class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
def clear_extra_info_of_changesets
|
def clear_extra_info_of_changesets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_hidden_repo?
|
||||||
|
if !User.current.member_of?(project)
|
||||||
|
if project.hidden_repo
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue