Commit 57c71f84 authored by Rin Toshaka's avatar Rin Toshaka
Browse files

Move generate_invite to user.ex

parent d924b6cd
defmodule Mix.Tasks.Pleroma.Gen.Invite do
use Mix.Task
@shortdoc "Generates a user invite token"
def run([]) do
Mix.Task.run("app.start")
with {:ok, token} <- Pleroma.UserInviteToken.create_token() do
Mix.shell().info("Generated user invite token")
url =
Pleroma.Web.Router.Helpers.redirect_url(
Pleroma.Web.Endpoint,
:registration_page,
token.token
)
IO.puts("URL: #{url}")
else
_ ->
Mix.shell().error("Could not create invite token.")
end
end
end
......@@ -6,7 +6,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
@moduledoc """
Manages Pleroma instance.
## Generate a new instance.
## Generate a new instance config.
mix pleroma.instance new [OPTION...]
......@@ -145,6 +145,7 @@ def run(["new" | rest]) do
end
end
defp escape_sh_path(path) do
~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
end
......
......@@ -16,6 +16,10 @@ 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
## Generate an invite link.
mix pleroma.user invite
## Delete the user's account.
......@@ -255,6 +259,26 @@ defp set_admin(nickname, value) do
end
end
def run(["invite"]) do
Mix.Task.run("app.start")
with {:ok, token} <- Pleroma.UserInviteToken.create_token() do
Mix.shell().info("Generated user invite token")
url =
Pleroma.Web.Router.Helpers.redirect_url(
Pleroma.Web.Endpoint,
:registration_page,
token.token
)
IO.puts(url)
else
_ ->
Mix.shell().error("Could not create invite token.")
end
end
defp set_locked(nickname, value) do
Mix.Ecto.ensure_started(Repo, [])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment