Merge branch 'password-reset-fix-for-non-test-env' into 'develop'
Fix password reset for non-test env See merge request pleroma/pleroma!1441
This commit is contained in:
commit
348307ec19
@ -1826,10 +1826,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
|> json("")
|
|> json("")
|
||||||
else
|
else
|
||||||
{:error, "unknown user"} ->
|
{:error, "unknown user"} ->
|
||||||
put_status(conn, :not_found)
|
send_resp(conn, :not_found, "")
|
||||||
|
|
||||||
{:error, _} ->
|
{:error, _} ->
|
||||||
put_status(conn, :bad_request)
|
send_resp(conn, :bad_request, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -221,6 +221,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||||||
user
|
user
|
||||||
|> UserEmail.password_reset_email(token_record.token)
|
|> UserEmail.password_reset_email(token_record.token)
|
||||||
|> Mailer.deliver_async()
|
|> Mailer.deliver_async()
|
||||||
|
|
||||||
|
{:ok, :enqueued}
|
||||||
else
|
else
|
||||||
false ->
|
false ->
|
||||||
{:error, "bad user identifier"}
|
{:error, "bad user identifier"}
|
||||||
|
@ -440,10 +440,10 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||||||
json_response(conn, :no_content, "")
|
json_response(conn, :no_content, "")
|
||||||
else
|
else
|
||||||
{:error, "unknown user"} ->
|
{:error, "unknown user"} ->
|
||||||
put_status(conn, :not_found)
|
send_resp(conn, :not_found, "")
|
||||||
|
|
||||||
{:error, _} ->
|
{:error, _} ->
|
||||||
put_status(conn, :bad_request)
|
send_resp(conn, :bad_request, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3849,14 +3849,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
test "it returns 404 when user is not found", %{conn: conn, user: user} do
|
test "it returns 404 when user is not found", %{conn: conn, user: user} do
|
||||||
conn = post(conn, "/auth/password?email=nonexisting_#{user.email}")
|
conn = post(conn, "/auth/password?email=nonexisting_#{user.email}")
|
||||||
assert conn.status == 404
|
assert conn.status == 404
|
||||||
refute conn.resp_body
|
assert conn.resp_body == ""
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns 400 when user is not local", %{conn: conn, user: user} do
|
test "it returns 400 when user is not local", %{conn: conn, user: user} do
|
||||||
{:ok, user} = Repo.update(Changeset.change(user, local: false))
|
{:ok, user} = Repo.update(Changeset.change(user, local: false))
|
||||||
conn = post(conn, "/auth/password?email=#{user.email}")
|
conn = post(conn, "/auth/password?email=#{user.email}")
|
||||||
assert conn.status == 400
|
assert conn.status == 400
|
||||||
refute conn.resp_body
|
assert conn.resp_body == ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1119,14 +1119,14 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||||||
test "it returns 404 when user is not found", %{conn: conn, user: user} do
|
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}")
|
conn = post(conn, "/api/account/password_reset?email=nonexisting_#{user.email}")
|
||||||
assert conn.status == 404
|
assert conn.status == 404
|
||||||
refute conn.resp_body
|
assert conn.resp_body == ""
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns 400 when user is not local", %{conn: conn, user: user} do
|
test "it returns 400 when user is not local", %{conn: conn, user: user} do
|
||||||
{:ok, user} = Repo.update(Changeset.change(user, local: false))
|
{:ok, user} = Repo.update(Changeset.change(user, local: false))
|
||||||
conn = post(conn, "/api/account/password_reset?email=#{user.email}")
|
conn = post(conn, "/api/account/password_reset?email=#{user.email}")
|
||||||
assert conn.status == 400
|
assert conn.status == 400
|
||||||
refute conn.resp_body
|
assert conn.resp_body == ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user