@@ -32,8 +32,10 class ApplicationController < ActionController::Base | |||
|
32 | 32 | end |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | # Returns the role that the logged in user has on the current project | |
|
36 | # or nil if current user is not a member of the project | |
|
35 | 37 | def logged_in_user_membership |
|
36 | @user_membership ||= Member.find(:first, :conditions => ["user_id=? and project_id=?", self.logged_in_user.id, @project.id]) | |
|
38 | @user_membership ||= logged_in_user.role_for_project(@project) | |
|
37 | 39 | end |
|
38 | 40 | |
|
39 | 41 | # check if login is globally required to access the application |
@@ -86,8 +88,7 class ApplicationController < ActionController::Base | |||
|
86 | 88 | # admin is always authorized |
|
87 | 89 | return true if self.logged_in_user.admin? |
|
88 | 90 | # if not admin, check membership permission |
|
89 | @user_membership ||= logged_in_user.role_for_project(@project) | |
|
90 | if @user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], @user_membership ) | |
|
91 | if logged_in_user_membership and Permission.allowed_to_role( "%s/%s" % [ ctrl, action ], logged_in_user_membership ) | |
|
91 | 92 | return true |
|
92 | 93 | end |
|
93 | 94 | render :nothing => true, :status => 403 |
General Comments 0
You need to be logged in to leave comments.
Login now