diff options
Diffstat (limited to 'lib/pleroma/web/twitter_api')
-rw-r--r-- | lib/pleroma/web/twitter_api/controllers/util_controller.ex | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 82ed0c287..644a0ae6b 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -31,6 +31,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do OAuthScopesPlug, %{scopes: ["write:accounts"]} when action in [ + :change_email, :change_password, :delete_account, :update_notificaton_settings, @@ -334,6 +335,25 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do end end + def change_email(%{assigns: %{user: user}} = conn, params) do + case CommonAPI.Utils.confirm_current_password(user, params["password"]) do + {:ok, user} -> + with {:ok, _user} <- User.change_email(user, params["email"]) do + json(conn, %{status: "success"}) + else + {:error, changeset} -> + {_, {error, _}} = Enum.at(changeset.errors, 0) + json(conn, %{error: "Email #{error}."}) + + _ -> + json(conn, %{error: "Unable to change email."}) + end + + {:error, msg} -> + json(conn, %{error: msg}) + end + end + def delete_account(%{assigns: %{user: user}} = conn, params) do case CommonAPI.Utils.confirm_current_password(user, params["password"]) do {:ok, user} -> |