Allow to edit account email and delete account
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -39,11 +39,12 @@ defmodule Mobilizon.Users.User do
|
||||
:confirmation_token,
|
||||
:reset_password_sent_at,
|
||||
:reset_password_token,
|
||||
:locale
|
||||
:locale,
|
||||
:unconfirmed_email
|
||||
]
|
||||
@attrs @required_attrs ++ @optional_attrs
|
||||
|
||||
@registration_required_attrs [:email, :password]
|
||||
@registration_required_attrs @required_attrs ++ [:password]
|
||||
|
||||
@password_change_required_attrs [:password]
|
||||
@password_reset_required_attrs @password_change_required_attrs ++
|
||||
@@ -61,6 +62,7 @@ defmodule Mobilizon.Users.User do
|
||||
field(:confirmation_token, :string)
|
||||
field(:reset_password_sent_at, :utc_datetime)
|
||||
field(:reset_password_token, :string)
|
||||
field(:unconfirmed_email, :string)
|
||||
field(:locale, :string, default: "en")
|
||||
|
||||
belongs_to(:default_actor, Actor)
|
||||
@@ -99,7 +101,7 @@ defmodule Mobilizon.Users.User do
|
||||
|> save_confirmation_token()
|
||||
|> unique_constraint(
|
||||
:confirmation_token,
|
||||
message: "The registration is already in use, this looks like an issue on our side."
|
||||
message: "The registration token is already in use, this looks like an issue on our side."
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ defmodule Mobilizon.Users do
|
||||
%User{}
|
||||
|> User.registration_changeset(args)
|
||||
|> Repo.insert() do
|
||||
Events.create_feed_token(%{"user_id" => user.id})
|
||||
Events.create_feed_token(%{user_id: user.id})
|
||||
|
||||
{:ok, user}
|
||||
end
|
||||
@@ -267,7 +267,10 @@ defmodule Mobilizon.Users do
|
||||
|
||||
@spec user_by_email_query(String.t(), boolean | nil) :: Ecto.Query.t()
|
||||
defp user_by_email_query(email, nil) do
|
||||
from(u in User, where: u.email == ^email, preload: :default_actor)
|
||||
from(u in User,
|
||||
where: u.email == ^email or u.unconfirmed_email == ^email,
|
||||
preload: :default_actor
|
||||
)
|
||||
end
|
||||
|
||||
defp user_by_email_query(email, true) do
|
||||
@@ -281,7 +284,7 @@ defmodule Mobilizon.Users do
|
||||
defp user_by_email_query(email, false) do
|
||||
from(
|
||||
u in User,
|
||||
where: u.email == ^email and is_nil(u.confirmed_at),
|
||||
where: (u.email == ^email or u.unconfirmed_email == ^email) and is_nil(u.confirmed_at),
|
||||
preload: :default_actor
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user