Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension point for handling access denied. #179

Merged
merged 2 commits into from
Jul 16, 2015
Merged

Add extension point for handling access denied. #179

merged 2 commits into from
Jul 16, 2015

Conversation

adammathys
Copy link
Member

Makes overriding desired behaviour when handling unauthorized requests much easier. It can be done on a per-controller basis and defined in outside extensions easily.

Spree::BaseController.unauthorized_redirect = -> do
  if try_spree_current_user
    flash[:error] = Spree.t(:authorization_failure)
    redirect_to spree.unauthorzied_path
  else
    store_location
    redirect_to spree.login_path
  end
end

Alternative to #43.

Makes overriding desired behaviour when handling unauthorized requests
much easier. It can be done on a per-controller basis and defined
in outside extensions easily.
@jhawthorn
Copy link
Contributor

👍

Is there a companion addition to solidus_auth_devise you can link to?

@Senjai
Copy link
Contributor

Senjai commented Jul 15, 2015

👍

2 similar comments
@magnusvk
Copy link
Contributor

👍

@forkata
Copy link
Contributor

forkata commented Jul 15, 2015

👍

@@ -8,8 +8,14 @@ module Auth
before_filter :set_guest_token
helper_method :try_spree_current_user

rescue_from CanCan::AccessDenied do |exception|
redirect_unauthorized_access
class_attribute :unauthorized_redirect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some documentation for this?

jhawthorn added a commit that referenced this pull request Jul 16, 2015
Add extension point for handling access denied.
@jhawthorn jhawthorn merged commit ab94a9d into solidusio:master Jul 16, 2015
@adammathys adammathys deleted the extensible-unauthorized-redirect branch July 16, 2015 17:19
spaghetticode referenced this pull request in nebulab/solidus Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants