Created
July 14, 2016 10:04
-
-
Save johnhamelink/6d53cee6d8a1920129f5766057781e34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defp ensure_sso_defaults(changeset) do | |
| # One of these fields needs to exist | |
| # for us to overwrite the email & password | |
| is_sso = ( | |
| get_field(changeset, :digits_id) || | |
| get_field(changeset, :facebook_id) || | |
| get_field(changeset, :sms_verification_id) | |
| ) | |
| changeset = | |
| if is_sso do | |
| # If the email or password fields aren't set, | |
| # then set them. | |
| if email = get_field(changeset, :email) == nil do | |
| changeset | |
| |> put_change(:email, | |
| "#{SecureRandom.urlsafe_base64(16)}@email.com") | |
| else | |
| changeset | |
| end | |
| if password = get_field(changeset, :password) == nil do | |
| changeset | |
| |> put_change(:encrypted_password, | |
| "#{SecureRandom.urlsafe_base64(16)}") | |
| else | |
| changeset | |
| end | |
| else | |
| changeset | |
| end | |
| changeset | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment