diff options
author | rinpatch <rinpatch@sdf.org> | 2019-06-19 19:51:38 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-06-19 19:51:38 +0000 |
commit | 524a66806d21ace82d3edab5e25eecb076a00305 (patch) | |
tree | 67485a127035c520ca3633e9722428446445f826 | |
parent | cb4fcc740cd77d9d7ed815f241402c21131eb450 (diff) | |
parent | 363618207c03188797be90b8c1cf7b3b293f557d (diff) | |
download | pleroma-524a66806d21ace82d3edab5e25eecb076a00305.tar.gz |
Merge branch 'user_sign_out_mix_task' into 'develop'
User sign out mix task
See merge request pleroma/pleroma!1309
-rw-r--r-- | lib/mix/tasks/pleroma/user.ex | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 7eaa49836..0efa745e4 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -8,6 +8,7 @@ defmodule Mix.Tasks.Pleroma.User do alias Mix.Tasks.Pleroma.Common alias Pleroma.User alias Pleroma.UserInviteToken + alias Pleroma.Web.OAuth @shortdoc "Manages Pleroma users" @moduledoc """ @@ -49,6 +50,10 @@ defmodule Mix.Tasks.Pleroma.User do mix pleroma.user delete_activities NICKNAME + ## Sign user out from all applications (delete user's OAuth tokens and authorizations). + + mix pleroma.user sign_out NICKNAME + ## Deactivate or activate the user's account. mix pleroma.user toggle_activated NICKNAME @@ -407,6 +412,20 @@ defmodule Mix.Tasks.Pleroma.User do end end + def run(["sign_out", nickname]) do + Common.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) + + Common.shell_info("#{nickname} signed out from all apps.") + else + _ -> + Common.shell_error("No local user #{nickname}") + end + end + defp set_moderator(user, value) do info_cng = User.Info.admin_api_update(user.info, %{is_moderator: value}) |