defmodule Mix.Tasks.Cartosnap.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 cartosnap.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 CartosnapApp.Accounts.rotate_invite_for_email(email) do
{:ok, invite} ->
Mix.shell().info(CartosnapAppWeb.invite_url(invite))
Mix.shell().info(
CartosnapApp.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 cartosnap.invite.link EMAIL")
end
neiam
/cartosnap_ex
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
931 B · text
History
e569b6d