From c7ddbc1162f3df3f6c2a9d69009491a25e662526 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 13 Oct 2020 14:36:55 +0200 Subject: [PATCH] Change CLI delete user task to completly delete user by default And document the new option Signed-off-by: Thomas Citharel --- docs/administration/CLI tasks/manage_users.md | 3 ++- lib/mix/tasks/mobilizon/users/delete.ex | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/administration/CLI tasks/manage_users.md b/docs/administration/CLI tasks/manage_users.md index 9a9e07dab..40c86fcf7 100644 --- a/docs/administration/CLI tasks/manage_users.md +++ b/docs/administration/CLI tasks/manage_users.md @@ -53,4 +53,5 @@ mix mobilizon.users.delete ### Options -* `--assume_yes`/`-y` Don't ask for confirmation \ No newline at end of file +* `--assume_yes`/`-y` Don't ask for confirmation +* `--keep_email`/`-k` Keep user entry with just email information (to prevent future registrations with same email) \ No newline at end of file diff --git a/lib/mix/tasks/mobilizon/users/delete.ex b/lib/mix/tasks/mobilizon/users/delete.ex index d95037dfb..545481835 100644 --- a/lib/mix/tasks/mobilizon/users/delete.ex +++ b/lib/mix/tasks/mobilizon/users/delete.ex @@ -15,23 +15,23 @@ defmodule Mix.Tasks.Mobilizon.Users.Delete do rest, strict: [ assume_yes: :boolean, - force: :boolean + keep_email: :boolean ], aliases: [ y: :assume_yes, - f: :force + f: :keep_email ] ) assume_yes? = Keyword.get(options, :assume_yes, false) - force? = Keyword.get(options, :force, false) + keep_email? = Keyword.get(options, :keep_email, false) Mix.Task.run("app.start") with {:ok, %User{} = user} <- Users.get_user_by_email(email), true <- assume_yes? or Mix.shell().yes?("Continue with deleting user #{user.email}?"), {:ok, %User{} = user} <- - Users.delete_user(user, reserve_email: !force?) do + Users.delete_user(user, reserve_email: keep_email?) do Mix.shell().info(""" The user #{user.email} has been deleted """)