admin_api_controller.ex: get_password_reset: fix params and response
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 12 Oct 2018 04:28:20 +0000 (06:28 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 19:25:54 +0000 (20:25 +0100)
lib/pleroma/web/admin_api/admin_api_controller.ex

index a6f8cd4d31e9d6cfb0707e73115cb5cf24f958ae..0cc84430d64bec10f067fac5bf8d94f895ec9d96 100644 (file)
@@ -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