-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Problem in validate_token if the model is in a namespace #69
Comments
Thanks @ybian! I'll create a test case for this scenario. |
The fix for this has been pushed into version |
I know this issue is old but still exists/reappears in 0.1.32.beta5 (could be other newer versions as well). I believe its more of an issue with how devise handles the key mapping with devise's mapping key produces: #routes.rb
mount_devise_token_auth_for 'Sassed::User', at: 'auth' module DeviseTokenAuth
class OmniauthCallbacksController < DeviseTokenAuth::ApplicationController
...
def redirect_callbacks
# The line below from original source code does not reflect
# the correct key value set by devise
# devise_mapping = request.env['omniauth.params']['resource_class'].underscore.to_sym
# producing, for example: :sassed/user
# A quick fix to make the keys match between devise and devise_token_auth
# is shown below by replacing the / with an underscore:
devise_mapping = request.env['omniauth.params']['resource_class'].underscore.gsub("/", "_").to_sym
redirect_route = "/#{Devise.mappings[devise_mapping].as_json["path"]}/#{params[:provider]}/callback"
# preserve omniauth info for success route
session['dta.omniauth.auth'] = request.env['omniauth.auth'].except(:extra)
session['dta.omniauth.params'] = request.env['omniauth.params']
redirect_to redirect_route
end
...
end Let me know if you need more information. Nice work on the gem! |
I think this might be related with #166 |
Hello, @mkralla11 @lynndylanhurley , is there a correct form of doing this ?
my routes.rb file
thank you, |
This issue (#355) "using namespaces in the user module" can also be solved by the previous answer! |
TestCase:
ng-token-auth
anddevise_token_auth_demo
properly and make it work correctly;User
to a namespace, say,Kuai::User
, and changeroutes.rb
accordingly to:mount_devise_token_auth_for 'Kuai::User', at: '/auth'
Expected Result:
Should confirm successfully.
Actual Result:
It seems confirmed. But immediately got the following exception:
The error seems in the following code snippets of
lib/devise_token_auth/rails/routes.rb
:if I changed it to:
It seemed to work but I'm not sure whether this is the right solution... Please take a look.
The text was updated successfully, but these errors were encountered: