X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fmix%2Ftasks%2Fpleroma%2Fuser.ex;h=d8400662d3fafbcb4bf5d957a80b4969673a6e2f;hb=0590d16089e4ffd52ac3e446f44aefd3f90dc38a;hp=0adb78fe3727ed83868ad424a59a2bdb25db475a;hpb=632dab5d30c39f4831b77bea9249b91b1b7b3347;p=akkoma
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index 0adb78fe3..d8400662d 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.User do
@@ -8,7 +8,6 @@ defmodule Mix.Tasks.Pleroma.User do
alias Ecto.Changeset
alias Pleroma.User
alias Pleroma.UserInviteToken
- alias Pleroma.Web.OAuth
@shortdoc "Manages Pleroma users"
@moduledoc File.read!("docs/administration/CLI_tasks/user.md")
@@ -101,8 +100,7 @@ defmodule Mix.Tasks.Pleroma.User do
User.perform(:delete, user)
shell_info("User #{nickname} deleted.")
else
- _ ->
- shell_error("No local user #{nickname}")
+ _ -> shell_error("No local user #{nickname}")
end
end
@@ -335,6 +333,35 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
+ def run(["change_email", nickname, email]) do
+ start_pleroma()
+ with %User{} = user <- User.get_cached_by_nickname(nickname) do
+ user
+ |> User.update_changeset(%{"email" => email})
+ |> User.update_and_set_cache()
+ shell_info("#{nickname}'s email updated")
+ end
+ end
+
+ def run(["show", nickname]) do
+ start_pleroma()
+ nickname
+ |> User.get_cached_by_nickname()
+ |> IO.inspect
+ end
+
+ def run(["send_confirmation", nickname]) do
+ start_pleroma()
+ with %User{} = user <- User.get_cached_by_nickname(nickname) do
+ user
+ |> Pleroma.Emails.UserEmail.account_confirmation_email()
+ |> IO.inspect
+ |> Pleroma.Emails.Mailer.deliver!()
+ shell_info("#{nickname}'s email sent")
+ end
+ end
+
+
def run(["toggle_confirmed", nickname]) do
start_pleroma()
@@ -354,8 +381,7 @@ defmodule Mix.Tasks.Pleroma.User do
start_pleroma()
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
- OAuth.Token.delete_user_tokens(user)
- OAuth.Authorization.delete_user_authorizations(user)
+ User.global_sign_out(user)
shell_info("#{nickname} signed out from all apps.")
else
@@ -393,10 +419,7 @@ defmodule Mix.Tasks.Pleroma.User do
end
defp set_admin(user, value) do
- {:ok, user} =
- user
- |> Changeset.change(%{is_admin: value})
- |> User.update_and_set_cache()
+ {:ok, user} = User.admin_api_update(user, %{is_admin: value})
shell_info("Admin status of #{user.nickname}: #{user.is_admin}")
user