mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Make email_valid handling consistent (#11556)
Previously we were checking truthiness in some places, and `== true` in others. That can lead to some inconsistent UX where the interface says the email is valid, but account creation fails. This commit ensures values are boolean when set, and raises an error for other value types. If this safety check is triggered, it means the specific auth provider needs to be updated to pass booleans.
This commit is contained in:
@@ -52,6 +52,13 @@ class Auth::Result
|
||||
@email&.downcase
|
||||
end
|
||||
|
||||
def email_valid=(val)
|
||||
if !val.in? [true, false, nil]
|
||||
raise ArgumentError, "email_valid should be boolean or nil"
|
||||
end
|
||||
@email_valid = !!val
|
||||
end
|
||||
|
||||
def failed?
|
||||
!!@failed
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user