-
Notifications
You must be signed in to change notification settings - Fork 21
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
#130 - Add Support for Multiple User Emails #266
base: main
Are you sure you want to change the base?
#130 - Add Support for Multiple User Emails #266
Conversation
@@ -10,7 +10,8 @@ | |||
import 'core-js/stable' | |||
import 'regenerator-runtime/runtime' | |||
|
|||
require("@rails/ujs").start() | |||
import Rails from "@rails/ujs" | |||
Rails.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -17,15 +17,6 @@ | |||
</div> | |||
<% end %> | |||
|
|||
<div class="field"> | |||
<div class="label"> | |||
<%= form.label :email, class: 'required' %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the ability to edit the email
field. Instead, users can add a new email or delete an existing one.
email.update!(primary: true) | ||
end | ||
|
||
flash[:notice] = "Your primary email has been ukpdated to #{email.email}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change 'ukpdated' to updated
def destroy | ||
email = Email.find(params[:id]) | ||
if email.destroy | ||
flash[:notice] = "Your email #{email.email} have been deleted." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change have to has
if email.destroy | ||
flash[:notice] = "Your email #{email.email} have been deleted." | ||
else | ||
flash[:error] = "Your email #{email.email} is failed to be deleted." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove is
This PR introduces the ability for users to associate multiple email addresses with their account. It addresses issue #130, which highlighted the need for this feature to prevent duplicate accounts and improve user experience, particularly for users who sign up with different emails (e.g., work and personal).
Key Changes:
Model Changes:
Email
model to store multiple email addresses associated with a user (belongs_to :user
).User
model tohas_many :emails
(must be declared before devisemulti_email_authenticatable
).Devise Integration:
devise-multi_email
gem to leverage its features for managing multiple emails within Devise.Controller Changes:
My::EmailsController
to handle:ReactivationsController
andMailingList::Sync
to use the user's primary email from theEmail
model.Mailer Changes:
trigger_after_confirmation
callback to theEmail
model to handle email updates after confirmation.View Changes:
my/emails
directory.my/details/show
view to display the user's associated email addresses and their confirmation status.Migration:
emails
table.null: false
constraint from theusers.email
column.Testing:
Email
model,My::EmailsController
, and other relevant components to ensure proper functionality.Migration Strategy for Existing Users:
users.email
column will temporarily allow null values.User.without_emails.find_each(&:update_emails)
in rails consoleusers.email
column will be removed or repurposed.Further Considerations (Out of Scope for this PR):
User.email
(e.g., notifications, other mailers).email
column in theUser
model.** UI changes
add new email
list emails
delete email