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

Warden failure fails when using autolocales #34

Open
happycze opened this issue Mar 23, 2017 · 7 comments
Open

Warden failure fails when using autolocales #34

happycze opened this issue Mar 23, 2017 · 7 comments

Comments

@happycze
Copy link

Hi guys,
im struggling with warden authentication failure when using autolocales from padrino-contrib. Without autolocales works following gist OK, with autolocales im getting empty screen on failure.
Please see gist for details https://gist.github.com/happycze/d09e337008f8ba209d6fc54899a2ebc7

Can you help me how to setup autolocales to get it work?
Thank you.

@happycze happycze changed the title Warden failure fails when using autolocales (padrino-contrib) Warden failure fails when using autolocales Mar 23, 2017
@wikimatze
Copy link
Member

Hm, I'm not seeing warden in your Gemfile? There is even padrino-warden although I haven't tested it. You can find a post about it under https://workaround.org/articlehow-to-use-user-authentication-in-your-padrino-apps-with-padrino-warden/.

@happycze
Copy link
Author

I know, already read this article, thank you. I'm using padrino-warden (0.20.2), warden (>= 0.10.3). Padrino contrib autolocales make /sessions/login path unavailable...

@adam12
Copy link
Contributor

adam12 commented Mar 26, 2017

Can you make a reproducible Github repo? Something we can clone and immediately see the failure.

@wikimatze
Copy link
Member

@adam12 is right, this would make helping you much easier.

@happycze
Copy link
Author

happycze commented Mar 27, 2017

There it is ;-) See https://github.com/happycze/autolocales

Shown autolocale issues:

  • warden authentication failure fail (create user first, then enter invalid credentials which results in "empty screen")
  • route named parameters fail on :lang key/symbol

If you disable autolocales, everything works as expected...

@adam12
Copy link
Contributor

adam12 commented Mar 28, 2017

Thanks for the reproducable app.

route named parameters fail on :lang key/symbol

I believe this is expected, as :lang is reserved for the locale name. We can't have duplicate param names.

warden authentication failure fail (create user first, then enter invalid credentials which results in "empty screen")

The empty screen is a 405 error. It's the result of the fail! call in your authentication file. I believe it's asking the Padrino app to handle the authentication failure but the AutoLocale middleware is mangling the path Padrino needs.

You can easily get something on the screen by using something like this in your app.rb file.

    set :warden_failure_app, proc {
      ->(env) { [200, {}, ["Foobar"]] }
    }

Unfortunately, I think you're hitting this bug #5 which has no fix.

@happycze
Copy link
Author

happycze commented Mar 28, 2017

Thank you for workaround, seems to work fine ;-)
I checked source code and you guys are right, :lang is reserved, its a pity, that there is no doc on this (at least i didn't find anything)

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

No branches or pull requests

3 participants