Skip to content

Instantly share code, notes, and snippets.

@kdiogenes
Created October 23, 2018 12:34
Show Gist options
  • Save kdiogenes/b8f825cc0c9d2910a4c05ceda75101cb to your computer and use it in GitHub Desktop.
Save kdiogenes/b8f825cc0c9d2910a4c05ceda75101cb to your computer and use it in GitHub Desktop.
phoenix: default coherence user
defmodule Pumpbits.Coherence.User do
@moduledoc false
use Ecto.Schema
use Coherence.Schema
use CoherenceAssent.Schema
alias Pumpbits.Repo
schema "users" do
field :name, :string
field :email, :string
coherence_schema()
coherence_assent_schema()
timestamps()
end
def changeset(model, params \\ %{}) do
model
|> cast(params, [:name, :email] ++ coherence_fields())
|> validate_required([:name, :email])
|> validate_format(:email, ~r/@/)
|> unique_constraint(:email)
|> validate_coherence_assent(params)
end
def changeset(model, params, :password) do
model
|> cast(params, ~w(password password_confirmation reset_password_token reset_password_sent_at))
|> validate_coherence_password_reset(params)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment