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

how to get first name and last name of user #953

Closed
anklos opened this issue Sep 12, 2017 · 4 comments
Closed

how to get first name and last name of user #953

anklos opened this issue Sep 12, 2017 · 4 comments

Comments

@anklos
Copy link

anklos commented Sep 12, 2017

Hi there,

this gem seems only retrieves name field from auth provider, rather than first_name and last_name: https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb#L84

Is there a way to get first_name and last_name by using this gem?

Thanks!

@dhurba87
Copy link

Auth provider provides name instead of first_name and last_name. You can split it to get first_name and last_name.

first_name = auth_hash['info']['name'].split(' ').first
last_name = auth_hash['info']['name'].split(' ').last

@lynndylanhurley
Copy link
Owner

You can also just remove the name column add those columns to the User migration.

@anklos
Copy link
Author

anklos commented Sep 15, 2017

@lynndylanhurley it will automatically work? that would be really nice.

if i keep the name and add first_name and last_name into the User migration, does all three columns get value stored?

Thanks!

@zachfeldman
Copy link
Contributor

I don't think it will automatically work @anklos , I think you have to override some of the create user methods. Feel free to reopen if you need help with that.

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

4 participants