diff --git a/app/models/auth_user.rb b/app/models/auth_user.rb index 21c33975..ec11cce1 100644 --- a/app/models/auth_user.rb +++ b/app/models/auth_user.rb @@ -118,14 +118,16 @@ class AuthUser < AuthRecord email_exists = AuthUser.where(email: auth.info.email).exists? user.email = auth.info.email unless email_exists end.tap do |user| - # Additionally, whether this account is new or existing, make sure - # we've saved the latest email to `neopass_email`. + # If this account already existed, make sure we've saved the latest + # email to `neopass_email`. # # We track this separately from `email`, which the user can edit, to # use in the Settings UI to indicate what NeoPass you're linked to. (In # practice, this *shouldn't* ever change after initial setup, because # NeoPass emails are immutable? But why not be resilient!) - user.update!(neopass_email: auth.info.email) + unless user.previously_new_record? + user.update!(neopass_email: auth.info.email) + end end end end