Move generate_invite to user.ex
This commit is contained in:
parent
d924b6cd3d
commit
57c71f8468
3 changed files with 26 additions and 25 deletions
|
@ -1,24 +0,0 @@
|
||||||
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 """
|
@moduledoc """
|
||||||
Manages Pleroma instance.
|
Manages Pleroma instance.
|
||||||
|
|
||||||
## Generate a new instance.
|
## Generate a new instance config.
|
||||||
|
|
||||||
mix pleroma.instance new [OPTION...]
|
mix pleroma.instance new [OPTION...]
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ def run(["new" | rest]) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
defp escape_sh_path(path) do
|
defp escape_sh_path(path) do
|
||||||
~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
|
~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,10 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
- `--password PASSWORD` - the user's password
|
- `--password PASSWORD` - the user's password
|
||||||
- `--moderator`/`--no-moderator` - whether the user is a moderator
|
- `--moderator`/`--no-moderator` - whether the user is a moderator
|
||||||
- `--admin`/`--no-admin` - whether the user is an admin
|
- `--admin`/`--no-admin` - whether the user is an admin
|
||||||
|
|
||||||
|
## Generate an invite link.
|
||||||
|
|
||||||
|
mix pleroma.user invite
|
||||||
|
|
||||||
## Delete the user's account.
|
## Delete the user's account.
|
||||||
|
|
||||||
|
@ -255,6 +259,26 @@ defp set_admin(nickname, value) do
|
||||||
end
|
end
|
||||||
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
|
defp set_locked(nickname, value) do
|
||||||
Mix.Ecto.ensure_started(Repo, [])
|
Mix.Ecto.ensure_started(Repo, [])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue