Created
January 13, 2023 08:08
-
-
Save softberries/26eb5095992c7508717ef07f055fcd26 to your computer and use it in GitHub Desktop.
This file contains 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
defmodule OauthTutorial.Accounts.User do | |
use Ecto.Schema | |
import Ecto.Changeset | |
schema "users" do | |
field :email, :string | |
field :provider, :string | |
field :token, :string | |
timestamps() | |
end | |
@doc false | |
def changeset(user, attrs) do | |
user | |
|> cast(attrs, [:email, :provider, :token]) | |
|> validate_required([:email, :provider, :token]) | |
|> unique_constraint(:email) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment