permission check in queries controller
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@89 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
e31070f21c
commit
de0a37e8b6
2 files changed
+5
-3
No files matched your search
@@ -71,9 +71,9 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# authorizes the user for the requested action.
|
# authorizes the user for the requested action.
|
||||||
def authorize
|
def authorize(ctrl = @params[:controller], action = @params[:action])
|
||||||
# check if action is allowed on public projects
|
# check if action is allowed on public projects
|
||||||
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ @params[:controller], @params[:action] ]
|
if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ]
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
# if action is not public, force login
|
# if action is not public, force login
|
||||||
@@ -82,7 +82,7 @@ class ApplicationController < ActionController::Base
|
|||||||
return true if self.logged_in_user.admin?
|
return true if self.logged_in_user.admin?
|
||||||
# if not admin, check membership permission
|
# if not admin, check membership permission
|
||||||
@user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
|
@user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id])
|
||||||
if @user_membership and Permission.allowed_to_role( "%s/%s" % [ @params[:controller], @params[:action] ], @user_membership.role_id )
|
if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership.role_id )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
render :nothing => true, :status => 403
|
render :nothing => true, :status => 403
|
||||||
|
|||||||
@@ -43,5 +43,7 @@ private
|
|||||||
def find_query
|
def find_query
|
||||||
@query = Query.find(params[:id])
|
@query = Query.find(params[:id])
|
||||||
@project = @query.project
|
@project = @query.project
|
||||||
|
# check if user is allowed to manage queries (same permission as add_query)
|
||||||
|
authorize('projects', 'add_query')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user