Merge branch 'delete-account-fix' into 'develop'
TwitterAPI: allow deleting one's own account with request body Closes #2799 and #2746 See merge request pleroma/pleroma!3564
This commit is contained in:
commit
6eb7d69e60
3 changed files with 49 additions and 5 deletions
|
|
@ -191,6 +191,7 @@ defmodule Pleroma.Web.ApiSpec.TwitterUtilOperation do
|
|||
parameters: [
|
||||
Operation.parameter(:password, :query, :string, "Password")
|
||||
],
|
||||
requestBody: request_body("Parameters", delete_account_request(), required: false),
|
||||
responses: %{
|
||||
200 =>
|
||||
Operation.response("Success", "application/json", %Schema{
|
||||
|
|
@ -237,4 +238,22 @@ defmodule Pleroma.Web.ApiSpec.TwitterUtilOperation do
|
|||
responses: %{200 => Operation.response("Web Page", "test/html", %Schema{type: :string})}
|
||||
}
|
||||
end
|
||||
|
||||
defp delete_account_request do
|
||||
%Schema{
|
||||
title: "AccountDeleteRequest",
|
||||
description: "POST body for deleting one's own account",
|
||||
type: :object,
|
||||
properties: %{
|
||||
password: %Schema{
|
||||
type: :string,
|
||||
description: "The user's own password for confirmation.",
|
||||
format: :password
|
||||
}
|
||||
},
|
||||
example: %{
|
||||
"password" => "prettyp0ony1313"
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -123,8 +123,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
end
|
||||
end
|
||||
|
||||
def delete_account(%{assigns: %{user: user}} = conn, params) do
|
||||
password = params[:password] || ""
|
||||
def delete_account(%{assigns: %{user: user}, body_params: body_params} = conn, params) do
|
||||
# This endpoint can accept a query param or JSON body for backwards-compatibility.
|
||||
# Submitting a JSON body is recommended, so passwords don't end up in server logs.
|
||||
password = body_params[:password] || params[:password] || ""
|
||||
|
||||
case CommonAPI.Utils.confirm_current_password(user, password) do
|
||||
{:ok, user} ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue