admin_api_controller.ex: get_password_reset: fix params and response

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-10-12 06:28:20 +02:00
parent 5732eef16b
commit 578a911737
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE

View file

@ -62,11 +62,23 @@ def get_invite_token(conn, _params) do
|> puts(token)
end
def get_password_reset(conn, %{nickname: nickname}) do
def get_password_reset(conn, %{"nickname" => nickname}) do
(%User{local: true} = user) = User.get_by_nickname(nickname)
{:ok, token} = Pleroma.PasswordResetToken.create_token(user)
conn
|> puts(token)
|> json(token.token)
end
def errors(conn, {:param_cast, _}) do
conn
|> put_status(400)
|> json("Invalid parameters")
end
def errors(conn, _) do
conn
|> put_status(500)
|> json("Something went wrong")
end
end