allow users to disable their own account

This commit is contained in:
Egor Kislitsyn 2019-03-04 19:55:11 +07:00
commit eb84de0143
16 changed files with 167 additions and 51 deletions

View file

@ -23,7 +23,7 @@ defmodule Mix.Tasks.Pleroma.User do
- `--password PASSWORD` - the user's password
- `--moderator`/`--no-moderator` - whether the user is a moderator
- `--admin`/`--no-admin` - whether the user is an admin
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
## Generate an invite link.
@ -37,6 +37,10 @@ defmodule Mix.Tasks.Pleroma.User do
mix pleroma.user toggle_activated NICKNAME
## Disable or enable the user's account.
mix pleroma.user toggle_disabled NICKNAME
## Unsubscribe local users from user's account and deactivate it
mix pleroma.user unsubscribe NICKNAME
@ -170,6 +174,20 @@ defmodule Mix.Tasks.Pleroma.User do
end
end
def run(["toggle_disabled", nickname]) do
Common.start_pleroma()
case User.get_by_nickname(nickname) do
%User{} = user ->
{:ok, user} = User.disable(user, !user.info.disabled)
status = if(user.info.disabled, do: "ON", else: "OFF")
Mix.shell().info("Disabled status of #{nickname}: #{status}")
_ ->
Mix.shell().error("No user #{nickname}")
end
end
def run(["reset_password", nickname]) do
Common.start_pleroma()