Change CLI delete user task to completly delete user by default
And document the new option Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
e90af944db
commit
1a3a3602d1
@ -53,4 +53,5 @@ mix mobilizon.users.delete <email>
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
* `--assume_yes`/`-y` Don't ask for confirmation
|
* `--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)
|
@ -15,23 +15,23 @@ defmodule Mix.Tasks.Mobilizon.Users.Delete do
|
|||||||
rest,
|
rest,
|
||||||
strict: [
|
strict: [
|
||||||
assume_yes: :boolean,
|
assume_yes: :boolean,
|
||||||
force: :boolean
|
keep_email: :boolean
|
||||||
],
|
],
|
||||||
aliases: [
|
aliases: [
|
||||||
y: :assume_yes,
|
y: :assume_yes,
|
||||||
f: :force
|
f: :keep_email
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
assume_yes? = Keyword.get(options, :assume_yes, false)
|
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")
|
Mix.Task.run("app.start")
|
||||||
|
|
||||||
with {:ok, %User{} = user} <- Users.get_user_by_email(email),
|
with {:ok, %User{} = user} <- Users.get_user_by_email(email),
|
||||||
true <- assume_yes? or Mix.shell().yes?("Continue with deleting user #{user.email}?"),
|
true <- assume_yes? or Mix.shell().yes?("Continue with deleting user #{user.email}?"),
|
||||||
{:ok, %User{} = user} <-
|
{:ok, %User{} = user} <-
|
||||||
Users.delete_user(user, reserve_email: !force?) do
|
Users.delete_user(user, reserve_email: keep_email?) do
|
||||||
Mix.shell().info("""
|
Mix.shell().info("""
|
||||||
The user #{user.email} has been deleted
|
The user #{user.email} has been deleted
|
||||||
""")
|
""")
|
||||||
|
Loading…
Reference in New Issue
Block a user