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

Updating users.email with confirmable enabled also updates uid. #1374

Open
nrikiji opened this issue Jan 16, 2020 · 2 comments
Open

Updating users.email with confirmable enabled also updates uid. #1374

nrikiji opened this issue Jan 16, 2020 · 2 comments

Comments

@nrikiji
Copy link

nrikiji commented Jan 16, 2020

Updating users.email will update the uid.
Is this correct behavior?
The expected behavior is that user.update (email: "xxxxx") does not update uid and email.
We expect these to be updated when we complete the change from the token given in the authentication email.

rails console

$ user = User.find(1)
$ user.update(email: "hoge@example.com")
User Update (0.5ms)  UPDATE `users` SET `users`.`uid` = 'hoge@example.com', `users`.`confirmation_token` = 'xxxxxxxxxxxxxx', `users`.`confirmation_sent_at` = '2020-01-16 08:55:22', `users`.`unconfirmed_email` = 'hoge@example.com
', `users`.`updated_at` = '2020-01-16 08:55:22' WHERE `users`.`id` = 1

app/models/user.rb

# frozen_string_literal: true                                                                                                                                                                                                                 

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :confirmable
  include DeviseTokenAuth::Concerns::User

  def postpone_email_change?
    true
  end
end

devise_token_auth gem version : 1.1.3
devise gem version : 4.7.1
ruby version : 2.6.5
rails version : 6.0.2.1

@pnghai
Copy link
Contributor

pnghai commented Jun 5, 2020

I have to manually backup the old email and change the uid back to old email when confirmable is set

@pnghai
Copy link
Contributor

pnghai commented Jun 5, 2020

#1407 here's my proposal

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