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?
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!)
unless user.previously_new_record?
user.update!(neopass_email: auth.info.email)
end
end
end
end
def self.build_unique_username
# Start with a base name like "neopass-kougra-".