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

omniauth not working, passthru #1053

Open
elbarto132 opened this issue Dec 29, 2021 · 2 comments
Open

omniauth not working, passthru #1053

elbarto132 opened this issue Dec 29, 2021 · 2 comments

Comments

@elbarto132
Copy link

Please complete all sections.

Configuration

  • Provider Gem: omniauth-facebook
  • Ruby Version: 3.0.0
  • Framework: rails 7.0.0
  • Platform: ubuntu

Expected Behavior

When I click on the link it should take me to Facebook.

Actual Behavior

I get "Not found. Authentication passthru".

Steps to Reproduce

https://github.com/elbarto132/omniauthprob
Clone it, start it, click on "Sign in with Facebook" link.

I followed the instructions here: https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview

@elbarto132
Copy link
Author

Follow up:
It's actually not an omniauth bug, but a Rails bug.
I got this error because clicking on the signup with Facebook link issued a GET request.
It's supposed to be a POST request, the default Devise link has "method: post" set, but it's not working.
For "method: post" to work on a link tag, JQuery is required. But even after adding the jquery-rails gem and requiring it in my application.js file clicking on the link still results in a GET request, so something is not working right with Rails / jquery-rails.
The easiest solution is to just use the "button_to" instead of the "link_to" helper for the login button, this doesn't require JQuery to issue a POST request and thus works correctly.

@mattr
Copy link

mattr commented Feb 16, 2022

I think this is likely due to turbo replacing rails-ujs.

The method: :post on link_to is a Rails UJS attribute; to achieve the same with turbo, replace it with data: { turbo_method: :post }. Or use button_to, which defaults to a POST request.

# old version (rails-ujs)
link_to "Sign in with Facebook", [url], method: :post 
# => "<a href='/[url]' data-method='post'>Sign in with Facebook</a>"

# new version (turbo)
link_to "Sign in with Facebook", [url], data: { turbo_method: :post }
# => "<a href='/[url]' data-turbo-method='post'>Sign in with Facebook</a>"

dgmstuart added a commit to dgmstuart/swing-out-london that referenced this issue May 23, 2022
This was removed in a previous commit (jquery-ujs). This is what makes
the unobtrusive javascript buttons on the login page and event edit page
(organiser token) work.

The more recent way to achieve the same result is with turbo:
omniauth/omniauth#1053 (comment)
dgmstuart added a commit to dgmstuart/swing-out-london that referenced this issue May 24, 2022
This was removed in a previous commit (jquery-ujs). This is what makes
the unobtrusive javascript buttons on the login page and event edit page
(organiser token) work.

The more recent way to achieve the same result is with turbo:
omniauth/omniauth#1053 (comment)
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

2 participants