end
cond do
- @registrations_open || !is_nil(token) && !token.used ->
+ @registrations_open || (!is_nil(token) && !token.used) ->
changeset = User.register_changeset(%User{}, params)
with {:ok, user} <- Repo.insert(changeset) do
Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end)
|> Jason.encode!()
- {:error, %{error: errors}}
+ {:error, %{error: errors}}
end
- !@registrations_open && is_nil(token) -> {:error, "Invalid token"}
- !@registrations_open && token.used -> {:error, "Expired token"}
+ !@registrations_open && is_nil(token) ->
+ {:error, "Invalid token"}
+
+ !@registrations_open && token.used ->
+ {:error, "Expired token"}
end
end
token = Repo.get_by(UserInviteToken, token: token.token)
assert token.used == true
+
assert UserView.render("show.json", %{user: user}) ==
- UserView.render("show.json", %{user: fetched_user})
+ UserView.render("show.json", %{user: fetched_user})
end
@moduletag skip: "needs 'registrations_open: false' in config"