diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-09-13 12:46:16 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-09-13 12:46:16 +0000 |
commit | 0d9609894f4f4557da2db62a33da1b8995c9e1d7 (patch) | |
tree | 76836a41a85f04c6cb07d4f1c6efba59013df649 /lib/pleroma/web/twitter_api/controllers/util_controller.ex | |
parent | f884987ace0f060860b2ece0304cfba0708505a5 (diff) | |
parent | 7b5c81b3918b7ff99f00e72194075f43c3f81165 (diff) | |
download | pleroma-0d9609894f4f4557da2db62a33da1b8995c9e1d7.tar.gz |
Merge branch 'feature/change-email' into 'develop'
Add email change endpoint
Closes #1156
See merge request pleroma/pleroma!1580
Diffstat (limited to 'lib/pleroma/web/twitter_api/controllers/util_controller.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/controllers/util_controller.ex | 19 |
1 files changed, 19 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 3405bd3b7..867787c57 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -314,6 +314,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} -> |