[#114] Added :user_id component to email confirmation path to improve the security.
Added tests for `confirm_email` action.
This commit is contained in:
parent
8adcd1e80f
commit
f69cbf4755
5 changed files with 26 additions and 10 deletions
|
|
@ -382,9 +382,11 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
end
|
||||
end
|
||||
|
||||
def confirm_email(conn, %{"token" => token}) do
|
||||
with %User{} = user <- User.get_by_confirmation_token(token),
|
||||
def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
|
||||
with %User{} = user <- Repo.get(User, uid),
|
||||
true <- user.local,
|
||||
true <- user.info.confirmation_pending,
|
||||
true <- user.info.confirmation_token == token,
|
||||
info_change <- User.Info.confirmation_changeset(user.info, :confirmed),
|
||||
changeset <- Changeset.change(user) |> Changeset.put_embed(:info, info_change),
|
||||
{:ok, _} <- User.update_and_set_cache(changeset) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue