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

View file

@ -118,17 +118,19 @@ class AuthUser < AuthRecord
email_exists = AuthUser.where(email: auth.info.email).exists? email_exists = AuthUser.where(email: auth.info.email).exists?
user.email = auth.info.email unless email_exists user.email = auth.info.email unless email_exists
end.tap do |user| end.tap do |user|
# Additionally, whether this account is new or existing, make sure # If this account already existed, make sure we've saved the latest
# we've saved the latest email to `neopass_email`. # email to `neopass_email`.
# #
# We track this separately from `email`, which the user can edit, to # 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 # use in the Settings UI to indicate what NeoPass you're linked to. (In
# practice, this *shouldn't* ever change after initial setup, because # practice, this *shouldn't* ever change after initial setup, because
# NeoPass emails are immutable? But why not be resilient!) # NeoPass emails are immutable? But why not be resilient!)
unless user.previously_new_record?
user.update!(neopass_email: auth.info.email) user.update!(neopass_email: auth.info.email)
end end
end end
end end
end
def self.build_unique_username def self.build_unique_username
# Start with a base name like "neopass-kougra-". # Start with a base name like "neopass-kougra-".