Skip to content

Store updated email in unconfirmed_email #1531

Merged
homu merged 4 commits into
rubygems:masterfrom
sonalkr132:email_update
Jan 5, 2017
Merged

Store updated email in unconfirmed_email #1531
homu merged 4 commits into
rubygems:masterfrom
sonalkr132:email_update

Conversation

@sonalkr132
Copy link
Copy Markdown
Member

@sonalkr132 sonalkr132 commented Dec 31, 2016

Closes #1512

After update of email, new email address will be stored in unconfirmed_email until it is confirmed. Until new email email address is confirmed, user will see following and their old email will remain their effective email address.
screenshot from 2017-01-05 11-36-03

@GBH
Copy link
Copy Markdown
Contributor

GBH commented Dec 31, 2016

👍 This is a good way to deal with email changes

Comment thread app/models/user.rb Outdated
end

def unconfirmed_email_exists?
User.where(email: unconfirmed_email).exists?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check against confirmed and unconfirmed emails. This is an edge condition but still:

  • User A: usera@email changes to new@email
  • User B: userb@email changes to new@email

Both confirm and it blows up in confirm_email! method for one of them

Comment thread app/models/user.rb Outdated
private

def unconfirmed_email_uniqueness
errors.add(:email, "#{unconfirmed_email} already exists") if unconfirmed_email_exists?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string should be in localized

Comment thread app/controllers/profiles_controller.rb Outdated
"your account with your new email address."
redirect_to_root
"minutes. It contains instructions for confirming " \
"your new email address."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string should be localized

when unconfirmed_email is verified with confirmation mail, it is copied
to email field.
@sonalkr132
Copy link
Copy Markdown
Member Author

Thanks for review @GBH 👍 I have included your suggestions and added option to re-sending confirmation mail for unconfirmed_email.

@indirect
Copy link
Copy Markdown

indirect commented Jan 5, 2017

Awesome. Thanks for implementing this, @sonalkr132! @homu r+

@homu
Copy link
Copy Markdown
Contributor

homu commented Jan 5, 2017

📌 Commit bea5318 has been approved by indirect

@homu
Copy link
Copy Markdown
Contributor

homu commented Jan 5, 2017

⚡ Test exempted - status

@homu homu merged commit bea5318 into rubygems:master Jan 5, 2017
homu added a commit that referenced this pull request Jan 5, 2017
Store updated email in unconfirmed_email

Closes #1512

After update of email, new email address will be stored in `unconfirmed_email` until it is confirmed. Until new email email address is confirmed, user will see following and their old email will remain their effective email address.
![screenshot from 2017-01-05 11-36-03](https://cloud.githubusercontent.com/assets/7680662/21670591/5dd5324e-d33b-11e6-8ef1-36b0e8fbdd2c.png)
@sonalkr132 sonalkr132 deleted the email_update branch January 6, 2017 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants