Skip to content

Fix devise mapping #540

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

Merged
merged 2 commits into from
Mar 15, 2016

Conversation

merqlove
Copy link
Contributor

Fix for #362

@ivawzh
Copy link

ivawzh commented Mar 14, 2016

This fails for me:

undefined method `underscore' for nil:NilClass

/Users/blah/.gem/ruby/2.3.0/bundler/gems/devise_token_auth-afe6da1951e4/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:13:in `redirect_callbacks

@merqlove
Copy link
Contributor Author

@ivawzh line 13? Here is nothing at this line.
Maybe you trying another pull?

@ivawzh
Copy link

ivawzh commented Mar 15, 2016

Yesterday I couldn't install this gem with Rails 5. So I manually merged the change, and then the error occurred. However, when I try it tonight, this pull is installed without any conflicts. And the gem is working as expected.

So 👍 . Thank you @merqlove. Hope this can be merged ASAP

@booleanbetrayal
Copy link
Collaborator

LGTM .. Thanks @merqlove !

@anklos
Copy link

anklos commented Mar 28, 2016

Hi @merqlove I am still having the undefined methodunderscore' for nil:NilClass` issue after merging this commit:

image

This issue happens when I open the url localhost:3000/omniauth/facebook and authorize the app

@merqlove
Copy link
Contributor Author

Hi, resource_class param still required. This exists before my fix.
Check params sent to/from Fb.

28 марта 2016 г., в 6:36, Shane Niu [email protected] написал(а):

Hi @merqlove I am still having the undefined methodunderscore' for nil:NilClass` issue after merging this commit:

This issue happens when I open the url localhost:3000/omniauth/facebook and authorize the app


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@anklos
Copy link

anklos commented Mar 28, 2016

@merqlove the value of request.env['omniauth.params] is an empty hash {}

is there anywhere I should set up the resource_class params?

Thanks!

@merqlove
Copy link
Contributor Author

@anklos
Copy link

anklos commented Mar 28, 2016

@merqlove yeah i followed the setup.

i put a break point above that line and restart the server. However server does not stop there before it crashes.

@merqlove
Copy link
Contributor Author

@anklos It means that you never call it. Can you post output of rake routes here and pick a route, which you trying to call?

@merqlove merqlove deleted the fix-devise-mapping branch March 28, 2016 10:49
@merqlove merqlove restored the fix-devise-mapping branch March 28, 2016 10:49
@anklos
Copy link

anklos commented Mar 28, 2016

@merqlove

rake routes:

new_user_session GET      /auth/sign_in(.:format)                devise_token_auth/sessions#new
            user_session POST     /auth/sign_in(.:format)                devise_token_auth/sessions#create
    destroy_user_session DELETE   /auth/sign_out(.:format)               devise_token_auth/sessions#destroy
           user_password POST     /auth/password(.:format)               devise_token_auth/passwords#create
       new_user_password GET      /auth/password/new(.:format)           devise_token_auth/passwords#new
      edit_user_password GET      /auth/password/edit(.:format)          devise_token_auth/passwords#edit
                         PATCH    /auth/password(.:format)               devise_token_auth/passwords#update
                         PUT      /auth/password(.:format)               devise_token_auth/passwords#update
cancel_user_registration GET      /auth/cancel(.:format)                 devise_token_auth/registrations#cancel
       user_registration POST     /auth(.:format)                        devise_token_auth/registrations#create
   new_user_registration GET      /auth/sign_up(.:format)                devise_token_auth/registrations#new
  edit_user_registration GET      /auth/edit(.:format)                   devise_token_auth/registrations#edit
                         PATCH    /auth(.:format)                        devise_token_auth/registrations#update
                         PUT      /auth(.:format)                        devise_token_auth/registrations#update
                         DELETE   /auth(.:format)                        devise_token_auth/registrations#destroy
       user_confirmation POST     /auth/confirmation(.:format)           devise_token_auth/confirmations#create
   new_user_confirmation GET      /auth/confirmation/new(.:format)       devise_token_auth/confirmations#new
                         GET      /auth/confirmation(.:format)           devise_token_auth/confirmations#show
     auth_validate_token GET      /auth/validate_token(.:format)         devise_token_auth/token_validations#validate_token
            auth_failure GET      /auth/failure(.:format)                devise_token_auth/omniauth_callbacks#omniauth_failure
                         GET      /auth/:provider/callback(.:format)     devise_token_auth/omniauth_callbacks#omniauth_success
                         GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks
        omniauth_failure GET|POST /omniauth/failure(.:format)            devise_token_auth/omniauth_callbacks#omniauth_failure
                         GET      /auth/:provider(.:format)              redirect(301)

I was calling GET /omniauth/facebook

I just tried to call GET /auth/facebook, the server did stop at break point. but there were other errors.

I am a bit confused now, which route I should use?

@anklos
Copy link

anklos commented Mar 28, 2016

if I do GET /auth/facebook and authorize the app, it can create a new user in my database, but url redirects to http://localhost:3000//auth/facebook/callback#_=_ and shows An error occurred on the page.

@merqlove
Copy link
Contributor Author

@anklos, hmm, looks weird.
do you have mount_devise_token_auth_for 'User', at: 'auth' or similar in routes.rb?

@anklos
Copy link

anklos commented Mar 28, 2016

yes I did this exactly mount_devise_token_auth_for 'User', at: 'auth'

@merqlove
Copy link
Contributor Author

@anklos good.
Look at here:

https://github.com/lynndylanhurley/devise_token_auth/blob/ad8c60695bcefbf9a21ea35d8b07059380fcb9bf/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb
auth_origin_url is must have in the query.

For example, how i test it:

it 'should signup with twitter and e-mail' do
      get_via_redirect '/api/v1/auth/twitter', email: '[email protected]', auth_origin_url: host
      expect(response).to be_success
      users = User.where(email: '[email protected]')
      check_data(users)
end

@anklos
Copy link

anklos commented Mar 28, 2016

@merqlove you are a legend!!!! Thanks so much!!

@muhammadyana
Copy link

muhammadyana commented Jun 13, 2019

hallo, i still get error when i try access http://localhost:4001/users/auth/google_oauth2?auth_origin_url=localhost:4001/ it still error undefined method underscore for nil:NilClass
anyone can inform me where i have to locate the auth_origin_url ? thanks.
image

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.

5 participants