lynndylanhurley / lynndylanhurley/devise_token_auth

Refactoring : Confirmations controller - useless `if redirect_url` condition

Open
#1,611 1 comment 0 reactions 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

**Version**: 1.2.2

in this section
https://github.com/lynndylanhurley/devise_token_auth/blob/eeed6422a025813010ac1dcb922661d05266e36e/app/controllers/devise_token_auth/confirmations_controller.rb#L29-L33
I was wondering why we are checking `if redirect_url` because it's necessary of having `DeviseTokenAuth.default_confirm_success_url` or `params[:redirect_url]` set.

In other words, imagine having this method returning nil
https://github.com/lynndylanhurley/devise_token_auth/blob/eeed6422a025813010ac1dcb922661d05266e36e/app/controllers/devise_token_auth/confirmations_controller.rb#L82-L87
It means that the sign_up flow would failed in this section
https://github.com/lynndylanhurley/devise_token_auth/blob/eeed6422a025813010ac1dcb922661d05266e36e/app/controllers/devise_token_auth/confirmations_controller.rb#L22-L25
and throw an exception of type `ArgumentError` saying `bad argument (expected URI object or URI string)`.

Maybe I missed something?

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 in app/controllers/devise_token_auth/confirmations_controller.rb at lines 22-33 and inspect the redirect_url method around lines 82-87. Reproduce the flow when that method returns nil, then determine whether the conditional is redundant or whether the nil path needs different handling. Done means the confirmation flow no longer raises the reported ArgumentError and the redirect behavior is intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, authentication
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.