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!
This commit is contained in:
Emi Matchu 2024-04-08 05:00:27 -07:00
parent 889c454c65
commit 09bccd41da
1 changed files with 5 additions and 3 deletions

View File

@ -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