Refactor User.confirm/1, add more tests

This commit is contained in:
Alex Gleason 2020-10-12 16:32:34 -05:00
commit 6ebec50df6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 89 additions and 5 deletions

View file

@ -31,11 +31,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
with %User{} = user <- User.get_cached_by_id(uid),
true <- user.local and user.confirmation_pending and user.confirmation_token == token,
{:ok, _} <-
user
|> User.confirmation_changeset(need_confirmation: false)
|> User.update_and_set_cache() do
User.post_register_action(user)
{:ok, _} <- User.confirm(user) do
redirect(conn, to: "/")
end
end