@@ -154,7 +154,15 class ApplicationController < ActionController::Base | |||
|
154 | 154 | # Authorize the user for the requested action |
|
155 | 155 | def authorize(ctrl = params[:controller], action = params[:action], global = false) |
|
156 | 156 | allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global) |
|
157 | allowed ? true : deny_access | |
|
157 | if allowed | |
|
158 | true | |
|
159 | else | |
|
160 | if @project && @project.archived? | |
|
161 | render_403 :message => :notice_not_authorized_archived_project | |
|
162 | else | |
|
163 | deny_access | |
|
164 | end | |
|
165 | end | |
|
158 | 166 | end |
|
159 | 167 | |
|
160 | 168 | # Authorize the user for the requested action outside a project |
@@ -265,8 +273,10 class ApplicationController < ActionController::Base | |||
|
265 | 273 | redirect_to default |
|
266 | 274 | end |
|
267 | 275 | |
|
268 | def render_403 | |
|
276 | def render_403(options={}) | |
|
269 | 277 | @project = nil |
|
278 | @message = options[:message] || :notice_not_authorized | |
|
279 | @message = l(@message) if @message.is_a?(Symbol) | |
|
270 | 280 | respond_to do |format| |
|
271 | 281 | format.html { render :template => "common/403", :layout => use_layout, :status => 403 } |
|
272 | 282 | format.atom { head 403 } |
@@ -220,6 +220,10 class Project < ActiveRecord::Base | |||
|
220 | 220 | self.status == STATUS_ACTIVE |
|
221 | 221 | end |
|
222 | 222 | |
|
223 | def archived? | |
|
224 | self.status == STATUS_ARCHIVED | |
|
225 | end | |
|
226 | ||
|
223 | 227 | # Archives the project and its descendants |
|
224 | 228 | def archive |
|
225 | 229 | # Check that there is no issue of a non descendant project that is assigned |
@@ -1,6 +1,6 | |||
|
1 | 1 | <h2>403</h2> |
|
2 | 2 | |
|
3 | <p><%= l(:notice_not_authorized) %></p> | |
|
3 | <p><%=h @message %></p> | |
|
4 | 4 | <p><a href="javascript:history.back()">Back</a></p> |
|
5 | 5 | |
|
6 | 6 | <% html_title '403' %> |
@@ -916,3 +916,4 bg: | |||
|
916 | 916 | label_user_mail_option_none: No events |
|
917 | 917 | field_member_of_group: Assignee's group |
|
918 | 918 | field_assigned_to_role: Assignee's role |
|
919 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -936,3 +936,4 bs: | |||
|
936 | 936 | label_user_mail_option_none: No events |
|
937 | 937 | field_member_of_group: Assignee's group |
|
938 | 938 | field_assigned_to_role: Assignee's role |
|
939 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -925,3 +925,4 ca: | |||
|
925 | 925 | label_user_mail_option_none: No events |
|
926 | 926 | field_member_of_group: Assignee's group |
|
927 | 927 | field_assigned_to_role: Assignee's role |
|
928 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -922,3 +922,4 cs: | |||
|
922 | 922 | label_user_mail_option_none: No events |
|
923 | 923 | field_member_of_group: Assignee's group |
|
924 | 924 | field_assigned_to_role: Assignee's role |
|
925 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -938,3 +938,4 da: | |||
|
938 | 938 | label_user_mail_option_none: No events |
|
939 | 939 | field_member_of_group: Assignee's group |
|
940 | 940 | field_assigned_to_role: Assignee's role |
|
941 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -941,3 +941,4 de: | |||
|
941 | 941 | label_user_mail_option_none: No events |
|
942 | 942 | field_member_of_group: Assignee's group |
|
943 | 943 | field_assigned_to_role: Assignee's role |
|
944 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -922,3 +922,4 el: | |||
|
922 | 922 | label_user_mail_option_none: No events |
|
923 | 923 | field_member_of_group: Assignee's group |
|
924 | 924 | field_assigned_to_role: Assignee's role |
|
925 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -926,3 +926,4 en-GB: | |||
|
926 | 926 | setting_default_notification_option: Default notification option |
|
927 | 927 | label_user_mail_option_only_my_events: Only for things I watch or I'm involved in |
|
928 | 928 | label_user_mail_option_only_assigned: Only for things I am assigned to |
|
929 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -150,6 +150,7 en: | |||
|
150 | 150 | notice_file_not_found: The page you were trying to access doesn't exist or has been removed. |
|
151 | 151 | notice_locking_conflict: Data has been updated by another user. |
|
152 | 152 | notice_not_authorized: You are not authorized to access this page. |
|
153 | notice_not_authorized_archived_project: The project you're trying to access has been archived. | |
|
153 | 154 | notice_email_sent: "An email was sent to {{value}}" |
|
154 | 155 | notice_email_error: "An error occurred while sending mail ({{value}})" |
|
155 | 156 | notice_feeds_access_key_reseted: Your RSS access key was reset. |
@@ -962,3 +962,4 es: | |||
|
962 | 962 | label_user_mail_option_none: No events |
|
963 | 963 | field_member_of_group: Assignee's group |
|
964 | 964 | field_assigned_to_role: Assignee's role |
|
965 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -926,3 +926,4 eu: | |||
|
926 | 926 | label_user_mail_option_none: No events |
|
927 | 927 | field_member_of_group: Assignee's group |
|
928 | 928 | field_assigned_to_role: Assignee's role |
|
929 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -947,3 +947,4 fi: | |||
|
947 | 947 | label_user_mail_option_none: No events |
|
948 | 948 | field_member_of_group: Assignee's group |
|
949 | 949 | field_assigned_to_role: Assignee's role |
|
950 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -169,6 +169,7 fr: | |||
|
169 | 169 | notice_file_not_found: "La page à laquelle vous souhaitez accéder n'existe pas ou a été supprimée." |
|
170 | 170 | notice_locking_conflict: Les données ont été mises à jour par un autre utilisateur. Mise à jour impossible. |
|
171 | 171 | notice_not_authorized: "Vous n'êtes pas autorisés à accéder à cette page." |
|
172 | notice_not_authorized_archived_project: Le projet auquel vous tentez d'accéder a été archivé. | |
|
172 | 173 | notice_email_sent: "Un email a été envoyé à {{value}}" |
|
173 | 174 | notice_email_error: "Erreur lors de l'envoi de l'email ({{value}})" |
|
174 | 175 | notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée." |
@@ -938,3 +938,4 gl: | |||
|
938 | 938 | label_user_mail_option_none: No events |
|
939 | 939 | field_member_of_group: Assignee's group |
|
940 | 940 | field_assigned_to_role: Assignee's role |
|
941 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -927,3 +927,4 he: | |||
|
927 | 927 | label_user_mail_option_none: No events |
|
928 | 928 | field_member_of_group: Assignee's group |
|
929 | 929 | field_assigned_to_role: Assignee's role |
|
930 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -929,3 +929,4 hr: | |||
|
929 | 929 | label_user_mail_option_none: No events |
|
930 | 930 | field_member_of_group: Assignee's group |
|
931 | 931 | field_assigned_to_role: Assignee's role |
|
932 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -945,3 +945,4 | |||
|
945 | 945 | label_user_mail_option_none: No events |
|
946 | 946 | field_member_of_group: Assignee's group |
|
947 | 947 | field_assigned_to_role: Assignee's role |
|
948 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -930,3 +930,4 id: | |||
|
930 | 930 | label_user_mail_option_none: No events |
|
931 | 931 | field_member_of_group: Assignee's group |
|
932 | 932 | field_assigned_to_role: Assignee's role |
|
933 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -926,3 +926,4 it: | |||
|
926 | 926 | label_user_mail_option_none: No events |
|
927 | 927 | field_member_of_group: Assignee's group |
|
928 | 928 | field_assigned_to_role: Assignee's role |
|
929 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -947,3 +947,4 ja: | |||
|
947 | 947 | label_user_mail_option_none: No events |
|
948 | 948 | field_member_of_group: Assignee's group |
|
949 | 949 | field_assigned_to_role: Assignee's role |
|
950 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -978,3 +978,4 ko: | |||
|
978 | 978 | label_user_mail_option_none: No events |
|
979 | 979 | field_member_of_group: Assignee's group |
|
980 | 980 | field_assigned_to_role: Assignee's role |
|
981 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -986,3 +986,4 lt: | |||
|
986 | 986 | label_user_mail_option_none: No events |
|
987 | 987 | field_member_of_group: Assignee's group |
|
988 | 988 | field_assigned_to_role: Assignee's role |
|
989 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -917,3 +917,4 lv: | |||
|
917 | 917 | label_user_mail_option_none: No events |
|
918 | 918 | field_member_of_group: Assignee's group |
|
919 | 919 | field_assigned_to_role: Assignee's role |
|
920 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -922,3 +922,4 mk: | |||
|
922 | 922 | label_user_mail_option_none: No events |
|
923 | 923 | field_member_of_group: Assignee's group |
|
924 | 924 | field_assigned_to_role: Assignee's role |
|
925 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -923,3 +923,4 mn: | |||
|
923 | 923 | label_user_mail_option_none: No events |
|
924 | 924 | field_member_of_group: Assignee's group |
|
925 | 925 | field_assigned_to_role: Assignee's role |
|
926 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -904,3 +904,4 nl: | |||
|
904 | 904 | label_user_mail_option_none: No events |
|
905 | 905 | field_member_of_group: Assignee's group |
|
906 | 906 | field_assigned_to_role: Assignee's role |
|
907 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -913,3 +913,4 | |||
|
913 | 913 | label_user_mail_option_none: No events |
|
914 | 914 | field_member_of_group: Assignee's group |
|
915 | 915 | field_assigned_to_role: Assignee's role |
|
916 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -943,3 +943,4 pl: | |||
|
943 | 943 | label_user_mail_option_none: No events |
|
944 | 944 | field_member_of_group: Assignee's group |
|
945 | 945 | field_assigned_to_role: Assignee's role |
|
946 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -946,3 +946,4 pt-BR: | |||
|
946 | 946 | label_user_mail_option_none: No events |
|
947 | 947 | field_member_of_group: Assignee's group |
|
948 | 948 | field_assigned_to_role: Assignee's role |
|
949 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -930,3 +930,4 pt: | |||
|
930 | 930 | label_user_mail_option_none: No events |
|
931 | 931 | field_member_of_group: Assignee's group |
|
932 | 932 | field_assigned_to_role: Assignee's role |
|
933 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -915,3 +915,4 ro: | |||
|
915 | 915 | label_user_mail_option_none: No events |
|
916 | 916 | field_member_of_group: Assignee's group |
|
917 | 917 | field_assigned_to_role: Assignee's role |
|
918 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -1039,3 +1039,4 ru: | |||
|
1039 | 1039 | label_user_mail_option_none: No events |
|
1040 | 1040 | field_member_of_group: Assignee's group |
|
1041 | 1041 | field_assigned_to_role: Assignee's role |
|
1042 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -917,3 +917,4 sk: | |||
|
917 | 917 | label_user_mail_option_none: No events |
|
918 | 918 | field_member_of_group: Assignee's group |
|
919 | 919 | field_assigned_to_role: Assignee's role |
|
920 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -918,3 +918,4 sl: | |||
|
918 | 918 | label_user_mail_option_none: No events |
|
919 | 919 | field_member_of_group: Assignee's group |
|
920 | 920 | field_assigned_to_role: Assignee's role |
|
921 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -922,3 +922,4 sr-YU: | |||
|
922 | 922 | label_user_mail_option_none: No events |
|
923 | 923 | field_member_of_group: Assignee's group |
|
924 | 924 | field_assigned_to_role: Assignee's role |
|
925 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -923,3 +923,4 sr: | |||
|
923 | 923 | label_user_mail_option_none: No events |
|
924 | 924 | field_member_of_group: Assignee's group |
|
925 | 925 | field_assigned_to_role: Assignee's role |
|
926 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -967,3 +967,4 sv: | |||
|
967 | 967 | label_user_mail_option_none: No events |
|
968 | 968 | field_member_of_group: Assignee's group |
|
969 | 969 | field_assigned_to_role: Assignee's role |
|
970 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -919,3 +919,4 th: | |||
|
919 | 919 | label_user_mail_option_none: No events |
|
920 | 920 | field_member_of_group: Assignee's group |
|
921 | 921 | field_assigned_to_role: Assignee's role |
|
922 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -945,3 +945,4 tr: | |||
|
945 | 945 | label_user_mail_option_none: No events |
|
946 | 946 | field_member_of_group: Assignee's group |
|
947 | 947 | field_assigned_to_role: Assignee's role |
|
948 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -918,3 +918,4 uk: | |||
|
918 | 918 | label_user_mail_option_none: No events |
|
919 | 919 | field_member_of_group: Assignee's group |
|
920 | 920 | field_assigned_to_role: Assignee's role |
|
921 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -977,3 +977,4 vi: | |||
|
977 | 977 | label_user_mail_option_none: No events |
|
978 | 978 | field_member_of_group: Assignee's group |
|
979 | 979 | field_assigned_to_role: Assignee's role |
|
980 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -1008,3 +1008,4 | |||
|
1008 | 1008 | label_user_mail_option_none: No events |
|
1009 | 1009 | field_member_of_group: Assignee's group |
|
1010 | 1010 | field_assigned_to_role: Assignee's role |
|
1011 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -940,3 +940,4 zh: | |||
|
940 | 940 | label_user_mail_option_none: No events |
|
941 | 941 | field_member_of_group: Assignee's group |
|
942 | 942 | field_assigned_to_role: Assignee's role |
|
943 | notice_not_authorized_archived_project: The project you're trying to access has been archived. |
@@ -296,6 +296,16 class ProjectsControllerTest < ActionController::TestCase | |||
|
296 | 296 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
297 | 297 | end |
|
298 | 298 | |
|
299 | def show_archived_project_should_be_denied | |
|
300 | project = Project.find_by_identifier('ecookbook') | |
|
301 | project.archive! | |
|
302 | ||
|
303 | get :show, :id => 'ecookbook' | |
|
304 | assert_response 403 | |
|
305 | assert_nil assigns(:project) | |
|
306 | assert_tag :tag => 'p', :content => /archived/ | |
|
307 | end | |
|
308 | ||
|
299 | 309 | def test_private_subprojects_hidden |
|
300 | 310 | get :show, :id => 'ecookbook' |
|
301 | 311 | assert_response :success |
@@ -102,6 +102,7 class ProjectTest < ActiveSupport::TestCase | |||
|
102 | 102 | @ecookbook.reload |
|
103 | 103 | |
|
104 | 104 | assert !@ecookbook.active? |
|
105 | assert @ecookbook.archived? | |
|
105 | 106 | assert !user.projects.include?(@ecookbook) |
|
106 | 107 | # Subproject are also archived |
|
107 | 108 | assert !@ecookbook.children.empty? |
@@ -129,6 +130,7 class ProjectTest < ActiveSupport::TestCase | |||
|
129 | 130 | assert @ecookbook.unarchive |
|
130 | 131 | @ecookbook.reload |
|
131 | 132 | assert @ecookbook.active? |
|
133 | assert !@ecookbook.archived? | |
|
132 | 134 | assert user.projects.include?(@ecookbook) |
|
133 | 135 | # Subproject can now be unarchived |
|
134 | 136 | @ecookbook_sub1.reload |
General Comments 0
You need to be logged in to leave comments.
Login now