diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-09-15 18:52:27 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-09-15 18:52:27 +0300 |
commit | efbc2edba17a7ee2d3e15bca5fa4f6cf8b4b5116 (patch) | |
tree | 086f3bb1ae6ca2fbb9909e69297a7dabea9061fb /lib/pleroma/web/twitter_api | |
parent | e6f43a831bdd2a381ed4de493344886f312f9a38 (diff) | |
parent | 9c64a25713790fefa8b5c419aeadf55113c17073 (diff) | |
download | pleroma-efbc2edba17a7ee2d3e15bca5fa4f6cf8b4b5116.tar.gz |
[#1234] Merge remote-tracking branch 'remotes/upstream/develop' into 1234-mastodon-2-4-3-oauth-scopes
# Conflicts:
# lib/pleroma/web/activity_pub/activity_pub_controller.ex
# lib/pleroma/web/router.ex
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} -> |