defmodule Mix.Tasks.Vigil.Invite.Link do
@shortdoc "Print a fresh link for an addressed registration invite"
@moduledoc """
A fresh link for the newest active invite addressed to an email, for one
whose link was lost: earlier links to it stop working.
mix vigil.invite.link sam@example.com
In a release: `bin/invite-link sam@example.com`.
"""
use Mix.Task
@requirements ["app.start"]
@impl Mix.Task
def run([email]) do
case Vigil.Accounts.rotate_invite_for_email(email) do
{:ok, invite} ->
Mix.shell().info(VigilWeb.invite_url(invite))
Mix.shell().info(Vigil.Release.describe(invite) <> " Any earlier link no longer works.")
{:error, _} ->
Mix.shell().error("No active invite for #{email}")
exit({:shutdown, 1})
end
end
def run(_), do: Mix.raise("Usage: mix vigil.invite.link EMAIL")
end
neiam
/vigil
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
878 B · text
History
5901e75