Skip to content

Instantly share code, notes, and snippets.

@softberries
Created January 13, 2023 08:08
Show Gist options
  • Save softberries/26eb5095992c7508717ef07f055fcd26 to your computer and use it in GitHub Desktop.
Save softberries/26eb5095992c7508717ef07f055fcd26 to your computer and use it in GitHub Desktop.
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