forked from mirrors/akkoma
formatting
This commit is contained in:
parent
f42ffbe9a8
commit
9c1cf1befb
2 changed files with 9 additions and 5 deletions
|
@ -143,7 +143,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
end
|
end
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
@registrations_open || !is_nil(token) && !token.used ->
|
@registrations_open || (!is_nil(token) && !token.used) ->
|
||||||
changeset = User.register_changeset(%User{}, params)
|
changeset = User.register_changeset(%User{}, params)
|
||||||
|
|
||||||
with {:ok, user} <- Repo.insert(changeset) do
|
with {:ok, user} <- Repo.insert(changeset) do
|
||||||
|
@ -158,8 +158,11 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||||
{:error, %{error: errors}}
|
{:error, %{error: errors}}
|
||||||
end
|
end
|
||||||
|
|
||||||
!@registrations_open && is_nil(token) -> {:error, "Invalid token"}
|
!@registrations_open && is_nil(token) ->
|
||||||
!@registrations_open && token.used -> {:error, "Expired token"}
|
{:error, "Invalid token"}
|
||||||
|
|
||||||
|
!@registrations_open && token.used ->
|
||||||
|
{:error, "Expired token"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
||||||
token = Repo.get_by(UserInviteToken, token: token.token)
|
token = Repo.get_by(UserInviteToken, token: token.token)
|
||||||
|
|
||||||
assert token.used == true
|
assert token.used == true
|
||||||
|
|
||||||
assert UserView.render("show.json", %{user: user}) ==
|
assert UserView.render("show.json", %{user: user}) ==
|
||||||
UserView.render("show.json", %{user: fetched_user})
|
UserView.render("show.json", %{user: fetched_user})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue