|> json("")
else
{:error, "unknown user"} ->
- put_status(conn, :not_found)
+ send_resp(conn, :not_found, "")
{:error, _} ->
- put_status(conn, :bad_request)
+ send_resp(conn, :bad_request, "")
end
end
user
|> UserEmail.password_reset_email(token_record.token)
|> Mailer.deliver_async()
+
+ {:ok, :enqueued}
else
false ->
{:error, "bad user identifier"}
json_response(conn, :no_content, "")
else
{:error, "unknown user"} ->
- put_status(conn, :not_found)
+ send_resp(conn, :not_found, "")
{:error, _} ->
- put_status(conn, :bad_request)
+ send_resp(conn, :bad_request, "")
end
end
test "it returns 404 when user is not found", %{conn: conn, user: user} do
conn = post(conn, "/auth/password?email=nonexisting_#{user.email}")
assert conn.status == 404
- refute conn.resp_body
+ assert conn.resp_body == ""
end
test "it returns 400 when user is not local", %{conn: conn, user: user} do
{:ok, user} = Repo.update(Changeset.change(user, local: false))
conn = post(conn, "/auth/password?email=#{user.email}")
assert conn.status == 400
- refute conn.resp_body
+ assert conn.resp_body == ""
end
end
end
test "it returns 404 when user is not found", %{conn: conn, user: user} do
conn = post(conn, "/api/account/password_reset?email=nonexisting_#{user.email}")
assert conn.status == 404
- refute conn.resp_body
+ assert conn.resp_body == ""
end
test "it returns 400 when user is not local", %{conn: conn, user: user} do
{:ok, user} = Repo.update(Changeset.change(user, local: false))
conn = post(conn, "/api/account/password_reset?email=#{user.email}")
assert conn.status == 400
- refute conn.resp_body
+ assert conn.resp_body == ""
end
end