lynndylanhurley / lynndylanhurley/devise_token_auth

dta_find_by doesn't respect request_keys

Open
#1,508 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
3.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

When posting issues, please include the following information to speed up the troubleshooting process:

  • Version: master

We have devise setup with custom request keys

devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, request_keys: [:email, :company_id]

But https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/concerns/set_user_by_token.rb#L78

only finds the first occurrence of rc instances, making login not working for our purposes.
If I try to override dta_find_by in the model I don't have access to request (where I store the current_company, nor to other attributes that could help me find the scoped user that wants to login.

Do you have any idea on how to solve this? Current attributes may help?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at app/controllers/devise_token_auth/concerns/set_user_by_token.rb around line 78 and inspect how dta_find_by selects a user during login. Reproduce the request_keys configuration with email and company_id, then confirm that login resolves the scoped user rather than only the first matching record.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.