This commit is contained in:
@ -21,6 +21,7 @@ defmodule Memex.Accounts.User do
|
||||
field :email, :string
|
||||
field :password, :string, virtual: true
|
||||
field :hashed_password, :string
|
||||
field :current_password, :string, virtual: true, redact: true
|
||||
field :confirmed_at, :utc_datetime_usec
|
||||
field :role, Ecto.Enum, values: [:admin, :user], default: :user
|
||||
field :locale, :string
|
||||
@ -192,6 +193,8 @@ defmodule Memex.Accounts.User do
|
||||
"""
|
||||
@spec validate_current_password(changeset(), String.t()) :: changeset()
|
||||
def validate_current_password(changeset, password) do
|
||||
changeset = cast(changeset, %{current_password: password}, [:current_password])
|
||||
|
||||
if valid_password?(changeset.data, password),
|
||||
do: changeset,
|
||||
else: changeset |> add_error(:current_password, dgettext("errors", "is not valid"))
|
||||
|
@ -15,6 +15,7 @@ defmodule Memex.Application do
|
||||
MemexWeb.Telemetry,
|
||||
# Start the PubSub system
|
||||
{Phoenix.PubSub, name: Memex.PubSub},
|
||||
{DNSCluster, query: Application.get_env(:memex, :dns_cluster_query) || :ignore},
|
||||
# Start the Endpoint (http/https)
|
||||
MemexWeb.Endpoint,
|
||||
# Add Oban
|
||||
|
Reference in New Issue
Block a user