name: :string,
bio: :string,
password: :string,
- moderator: :boolean
+ moderator: :boolean,
+ admin: :boolean
]
)
end
moderator? = Keyword.get(options, :moderator, false)
+ admin? = Keyword.get(options, :admin, false)
Mix.shell().info("""
A user will be created with the following information:
- name: #{name}
- bio: #{bio}
- moderator: #{if(moderator?, do: "true", else: "false")}
+ - admin: #{if(admin?, do: "true", else: "false")}
""")
proceed? = Mix.shell().yes?("Continue?")
run(["set", nickname, "--moderator"])
end
+ if admin? do
+ run(["set", nickname, "--admin"])
+ end
+
if generated_password? do
run(["reset_password", nickname])
end
+
else
Mix.shell().info("User will not be created.")
end
with %User{local: true} = user <- User.get_by_nickname(nickname) do
User.delete(user)
+ Mix.shell().info("User #{nickname} deleted.")
+ else
+ _ ->
+ Mix.shell().error("No local user #{nickname}")
end
-
- Mix.shell().info("User #{nickname} deleted.")
end
def run(["toggle_activated", nickname]) do
Mix.Task.run("app.start")
- with user <- User.get_by_nickname(nickname) do
+ with %User{local: true} = user <- User.get_by_nickname(nickname) do
User.deactivate(user, !user.info["deactivated"])
+ Mix.shell().info("Activation status of #{nickname}: #{user.info["deactivated"]}")
+ else
+ _ ->
+ Mix.shell().error("No local user #{nickname}")
end
end