forked from OpenNeo/impress
Fix error when multiple accounts have a blank email address
This commit is contained in:
parent
ed89380152
commit
3e92d89765
1 changed files with 5 additions and 0 deletions
|
@ -10,6 +10,11 @@ class AuthUser < AuthRecord
|
||||||
|
|
||||||
has_one :user, foreign_key: :remote_id, inverse_of: :auth_user
|
has_one :user, foreign_key: :remote_id, inverse_of: :auth_user
|
||||||
|
|
||||||
|
# If the email is blank, ensure that it's `nil` rather than an empty string,
|
||||||
|
# or else the database's uniqueness constraint will object to multiple users
|
||||||
|
# who all have the empty string as their email.
|
||||||
|
before_validation { self.email = nil if email.blank? }
|
||||||
|
|
||||||
# It's important to keep AuthUser and User in sync. When we create an AuthUser
|
# It's important to keep AuthUser and User in sync. When we create an AuthUser
|
||||||
# (e.g. through the registration process), we create a matching User, too. And
|
# (e.g. through the registration process), we create a matching User, too. And
|
||||||
# when the AuthUser's name changes, we update User to match.
|
# when the AuthUser's name changes, we update User to match.
|
||||||
|
|
Loading…
Reference in a new issue