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

Find User by email and extra attributes #311

Open
diegossilveira opened this issue Jul 20, 2015 · 1 comment
Open

Find User by email and extra attributes #311

diegossilveira opened this issue Jul 20, 2015 · 1 comment

Comments

@diegossilveira
Copy link

Hello,

We have an application that uses devise_token_auth to accomplish token based authentication features. A new feature requires that we must have multiple users with the same email address in our database with an extra attribute that put each user in a different scope: something like a tenant_id.

Looking at devise_token_auth code, we figured out that the only way to customize User search query is to override sessions_controller.rb:

q = "#{field.to_s} = ? AND provider='email'"

I believe a better approach is to define a method on the model (authentication subject) by convention and pass it all the parameters from the controller, so the query could be easily customizable. A default implementation of this method (with the current query) could be supplied on DeviseTokenAuth::Concerns::User.

Is there a good reason for not doing so?

@goelinsights
Copy link

@diegossilveira did you ever figure out a path forward? Looking at some similar multi-tenant issues where user email may be tied to multiple tenants and trying to figure this out.

Is an alternate approach potentially to add a tenant_name as an extra field in the token?

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