From 578a9117370c3756c56448ad663664f73155a50b Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 12 Oct 2018 06:28:20 +0200 Subject: [PATCH] admin_api_controller.ex: get_password_reset: fix params and response --- .../web/admin_api/admin_api_controller.ex | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex index a6f8cd4d3..0cc84430d 100644 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@ -62,11 +62,23 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController 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 -- 2.45.2