Commit eea456ed authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Improved error message when trying to access an archived project (#2995).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4285 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 1e4776fa
......@@ -154,7 +154,15 @@ class ApplicationController < ActionController::Base
# Authorize the user for the requested action
def authorize(ctrl = params[:controller], action = params[:action], global = false)
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
allowed ? true : deny_access
if allowed
true
else
if @project && @project.archived?
render_403 :message => :notice_not_authorized_archived_project
else
deny_access
end
end
end
# Authorize the user for the requested action outside a project
......@@ -265,8 +273,10 @@ class ApplicationController < ActionController::Base
redirect_to default
end
def render_403
def render_403(options={})
@project = nil
@message = options[:message] || :notice_not_authorized
@message = l(@message) if @message.is_a?(Symbol)
respond_to do |format|
format.html { render :template => "common/403", :layout => use_layout, :status => 403 }
format.atom { head 403 }
......
......@@ -220,6 +220,10 @@ class Project < ActiveRecord::Base
self.status == STATUS_ACTIVE
end
def archived?
self.status == STATUS_ARCHIVED
end
# Archives the project and its descendants
def archive
# Check that there is no issue of a non descendant project that is assigned
......
<h2>403</h2>
<p><%= l(:notice_not_authorized) %></p>
<p><%=h @message %></p>
<p><a href="javascript:history.back()">Back</a></p>
<% html_title '403' %>
......@@ -916,3 +916,4 @@ bg:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -936,3 +936,4 @@ bs:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -925,3 +925,4 @@ ca:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -922,3 +922,4 @@ cs:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -938,3 +938,4 @@ da:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -941,3 +941,4 @@ de:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -922,3 +922,4 @@ el:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -926,3 +926,4 @@ en-GB:
setting_default_notification_option: Default notification option
label_user_mail_option_only_my_events: Only for things I watch or I'm involved in
label_user_mail_option_only_assigned: Only for things I am assigned to
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -150,6 +150,7 @@ en:
notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
notice_locking_conflict: Data has been updated by another user.
notice_not_authorized: You are not authorized to access this page.
notice_not_authorized_archived_project: The project you're trying to access has been archived.
notice_email_sent: "An email was sent to {{value}}"
notice_email_error: "An error occurred while sending mail ({{value}})"
notice_feeds_access_key_reseted: Your RSS access key was reset.
......
......@@ -962,3 +962,4 @@ es:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -926,3 +926,4 @@ eu:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -947,3 +947,4 @@ fi:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -169,6 +169,7 @@ fr:
notice_file_not_found: "La page à laquelle vous souhaitez accéder n'existe pas ou a été supprimée."
notice_locking_conflict: Les données ont été mises à jour par un autre utilisateur. Mise à jour impossible.
notice_not_authorized: "Vous n'êtes pas autorisés à accéder à cette page."
notice_not_authorized_archived_project: Le projet auquel vous tentez d'accéder a été archivé.
notice_email_sent: "Un email a été envoyé à {{value}}"
notice_email_error: "Erreur lors de l'envoi de l'email ({{value}})"
notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée."
......
......@@ -938,3 +938,4 @@ gl:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -927,3 +927,4 @@ he:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -929,3 +929,4 @@ hr:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -945,3 +945,4 @@
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -930,3 +930,4 @@ id:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -926,3 +926,4 @@ it:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -947,3 +947,4 @@ ja:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -978,3 +978,4 @@ ko:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -986,3 +986,4 @@ lt:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -917,3 +917,4 @@ lv:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -922,3 +922,4 @@ mk:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -923,3 +923,4 @@ mn:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -904,3 +904,4 @@ nl:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -913,3 +913,4 @@
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -943,3 +943,4 @@ pl:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -946,3 +946,4 @@ pt-BR:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -930,3 +930,4 @@ pt:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -915,3 +915,4 @@ ro:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -1039,3 +1039,4 @@ ru:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -917,3 +917,4 @@ sk:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -918,3 +918,4 @@ sl:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -922,3 +922,4 @@ sr-YU:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -923,3 +923,4 @@ sr:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -967,3 +967,4 @@ sv:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -919,3 +919,4 @@ th:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -945,3 +945,4 @@ tr:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -918,3 +918,4 @@ uk:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -977,3 +977,4 @@ vi:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -1008,3 +1008,4 @@
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -940,3 +940,4 @@ zh:
label_user_mail_option_none: No events
field_member_of_group: Assignee's group
field_assigned_to_role: Assignee's role
notice_not_authorized_archived_project: The project you're trying to access has been archived.
......@@ -296,6 +296,16 @@ class ProjectsControllerTest < ActionController::TestCase
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
end
def show_archived_project_should_be_denied
project = Project.find_by_identifier('ecookbook')
project.archive!
get :show, :id => 'ecookbook'
assert_response 403
assert_nil assigns(:project)
assert_tag :tag => 'p', :content => /archived/
end
def test_private_subprojects_hidden
get :show, :id => 'ecookbook'
assert_response :success
......
......@@ -102,6 +102,7 @@ class ProjectTest < ActiveSupport::TestCase
@ecookbook.reload
assert !@ecookbook.active?
assert @ecookbook.archived?
assert !user.projects.include?(@ecookbook)
# Subproject are also archived
assert !@ecookbook.children.empty?
......@@ -129,6 +130,7 @@ class ProjectTest < ActiveSupport::TestCase
assert @ecookbook.unarchive
@ecookbook.reload
assert @ecookbook.active?
assert !@ecookbook.archived?
assert user.projects.include?(@ecookbook)
# Subproject can now be unarchived
@ecookbook_sub1.reload
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment