From 09bccd41daffaf23b7a9be199078a3fd2f73d07e Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Mon, 8 Apr 2024 05:00:27 -0700 Subject: [PATCH] Oops, stop saying "Welcome back" for new NeoPass users! Ahh I see, if you do a no-op update, it still clears the `previously_new_record?` state, so our NeoPass controller thinks this account already existed. Instead, let's only do this update if it's an account that already exists, instead of depending on the no-op-iness! --- app/models/auth_user.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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