Guest User

Untitled

a guest
Oct 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. defmodule Pumpbits.Coherence.User do
  2. @moduledoc false
  3. use Ecto.Schema
  4. use Coherence.Schema
  5. use CoherenceAssent.Schema
  6. alias Pumpbits.Repo
  7.  
  8. schema "users" do
  9. field :name, :string
  10. field :email, :string
  11. coherence_schema()
  12. coherence_assent_schema()
  13.  
  14. timestamps()
  15. end
  16.  
  17. def changeset(model, params \\ %{}) do
  18. model
  19. |> cast(params, [:name, :email] ++ coherence_fields())
  20. |> validate_required([:name, :email])
  21. |> validate_format(:email, ~r/@/)
  22. |> unique_constraint(:email)
  23. |> validate_coherence_assent(params)
  24. end
  25.  
  26. def changeset(model, params, :password) do
  27. model
  28. |> cast(params, ~w(password password_confirmation reset_password_token reset_password_sent_at))
  29. |> validate_coherence_password_reset(params)
  30. end
  31. end
Add Comment
Please, Sign In to add comment