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

Set failure_app per scope, instead of failure_action? #40

Closed
JeanMertz opened this issue Feb 3, 2012 · 2 comments · May be fixed by #193
Closed

Set failure_app per scope, instead of failure_action? #40

JeanMertz opened this issue Feb 3, 2012 · 2 comments · May be fixed by #193

Comments

@JeanMertz
Copy link

I was wondering if it's possible to set the failure_app per scope.

This is my current setup:

Rails.application.config.middleware.use Warden::Manager do |config|
  config.failure_app = lambda { |env| SessionsController.action(:new).call(env) }
  config.default_scope = :user

  config.scope_defaults :backend,   strategies: [:password], store: true, action: :backend_new
  config.scope_defaults :frontend,  strategies: [:password], store: true, action: :frontend_new

end

However, keeping everything REST-ful and since the scenario's of logging in from the backend or the frontend differ a lot, I'd rather be able to set the failure app to Backend::SessionsController.action(:new) for one scope, and Frontend::SessionsController.action(:new) for the other.

Is this possible, and if not, is there a reason for this, am I trying to solve this problem the wrong way?

@josevalim
Copy link
Contributor

It should be possible, but the simplest way to solve this problem is setting the failure app to a FailureApp that will redirect to a controller and action according to the scope.

@JeanMertz
Copy link
Author

Wow, fastest reply ever? :-)

I figured I'd had to go this route, but it requires an extra redirect, so I was hoping to handle this from within Warden itself. Anyway, thank you for the quick solution, it works nicely, that's what counts.

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 a pull request may close this issue.

2 participants