renaming AccessDenied exception to Unauthorized
This commit is contained in:
@@ -219,7 +219,7 @@ module CanCan
|
||||
attribute = args.first
|
||||
if cannot?(action, subject, *args)
|
||||
message ||= unauthorized_message(action, subject)
|
||||
raise AccessDenied.new(message, action, subject)
|
||||
raise Unauthorized.new(message, action, subject)
|
||||
elsif sufficient_attribute_check?(action, subject, attribute) && sufficient_condition_check?(action, subject)
|
||||
fully_authorized!(action, subject)
|
||||
end
|
||||
|
||||
@@ -292,7 +292,7 @@ module CanCan
|
||||
base.helper_method :can?, :cannot?
|
||||
end
|
||||
|
||||
# Raises a CanCan::AccessDenied exception if the current_ability cannot
|
||||
# Raises a CanCan::Unauthorized exception if the current_ability cannot
|
||||
# perform the given action. This is usually called in a controller action or
|
||||
# before filter to perform the authorization.
|
||||
#
|
||||
@@ -319,12 +319,12 @@ module CanCan
|
||||
# access is displayed to the user.
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# rescue_from CanCan::AccessDenied do |exception|
|
||||
# rescue_from CanCan::Unauthorized do |exception|
|
||||
# redirect_to root_url, :alert => exception.message
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# See the CanCan::AccessDenied exception for more details on working with the exception.
|
||||
# See the CanCan::Unauthorized exception for more details on working with the exception.
|
||||
#
|
||||
# See the load_and_authorize_resource method to automatically add the authorize! behavior
|
||||
# to the default RESTful actions.
|
||||
|
||||
@@ -163,7 +163,7 @@ module CanCan
|
||||
elsif @options[:shallow]
|
||||
resource_class
|
||||
else
|
||||
raise AccessDenied # maybe this should be a record not found error instead?
|
||||
raise Unauthorized # maybe this should be a record not found error instead?
|
||||
end
|
||||
else
|
||||
resource_class
|
||||
|
||||
@@ -18,7 +18,7 @@ module CanCan
|
||||
# This usually happens within a call to ControllerAdditions#authorize! but can be
|
||||
# raised manually.
|
||||
#
|
||||
# raise CanCan::AccessDenied.new("Not authorized!", :read, Article)
|
||||
# raise CanCan::Unauthorized.new("Not authorized!", :read, Article)
|
||||
#
|
||||
# The passed message, action, and subject are optional and can later be retrieved when
|
||||
# rescuing from the exception.
|
||||
@@ -33,9 +33,9 @@ module CanCan
|
||||
# exception.default_message = "Default error message"
|
||||
# exception.message # => "Default error message"
|
||||
#
|
||||
# See ControllerAdditions#authorized! for more information on rescuing from this exception
|
||||
# See ControllerAdditions#authorize! for more information on rescuing from this exception
|
||||
# and customizing the message using I18n.
|
||||
class AccessDenied < Error
|
||||
class Unauthorized < Error
|
||||
attr_reader :action, :subject
|
||||
attr_writer :default_message
|
||||
|
||||
|
||||
Reference in New Issue
Block a user