Created
October 23, 2018 12:34
-
-
Save kdiogenes/b8f825cc0c9d2910a4c05ceda75101cb to your computer and use it in GitHub Desktop.
phoenix: default coherence user
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 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