一键导入
invitations
Use when wiring or customizing the teams invitation flow — emailing a user to join a team, the Swoosh notifier, and accepting an invite on sign-in.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when wiring or customizing the teams invitation flow — emailing a user to join a team, the Swoosh notifier, and accepting an invite on sign-in.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the app needs branded 404 and 500 error pages and a way to raise not-found from LiveViews. Covers install, the Fallback exception, and tweaking the templates.
Use when the app needs an admin-only dashboard at `/admin` for managing users, teams, and admins, with charts, impersonation, and the LiveDashboard. Covers install, configuration, and tweaks.
Use when authenticated routes must be gated behind email confirmation, redirecting users whose `confirmed_at` is nil to a confirmation page. Covers install, configuration, and tweaks for the confirmation gate.
Use when the app needs user accounts, sign-in, and roles. Covers installing phx.gen.auth-based auth with role-based access, profiles, and admin bootstrapping, plus how to tweak it.
Use when the app needs a Cmd+K/Ctrl+K command palette for quick navigation and search. Covers installing the LiveView palette, its protocol-based result formatting, and how to make resources searchable.
Use when the app needs database-backed error tracking without an external SaaS. Covers installing ErrorTracker with automatic Phoenix/LiveView/Oban reporting, migrations, pruning, and a dashboard.
| name | invitations |
| description | Use when wiring or customizing the teams invitation flow — emailing a user to join a team, the Swoosh notifier, and accepting an invite on sign-in. |
| user-invocable | true |
The teams feature ships an email invitation flow. An owner creates an
Invitation for an email; a Swoosh notifier emails a sign-in link; once the
invitee signs in, you turn the pending invitation into a membership.
../SKILL.md first for install and scoping.MyApp.Teams.create_invitation/3 inserts the invitation and pipes the result
through invite_member/1, which calls the notifier:
# lib/my_app/teams.ex
def create_invitation(team, user, attrs \\ %{}) do
%Invitation{}
|> Invitation.changeset(attrs)
|> Ecto.Changeset.put_assoc(:team, team)
|> Ecto.Changeset.put_assoc(:invited_by, user)
|> Repo.insert()
|> invite_member()
end
The notifier sends a plain-text email with a log-in URL:
# lib/my_app/teams/invitation_notifier.ex
def invite_user_email(%{email: email, url: url}) do
new()
|> to(email)
|> from({"Phoenix Team", "team@example.com"})
|> subject("Invited to join")
|> text_body("...#{url}...")
|> Mailer.deliver()
end
Pending invitations for the current user are found by email:
MyApp.Teams.list_invitations_for_user(user) # email match, accepted_at IS NULL
Customize the sender and copy in lib/my_app/teams/invitation_notifier.ex:
|> from({"Acme", "team@acme.test"})
|> subject("You're invited to join #{team_name} on Acme")
Accept an invitation after the invitee signs in — create the membership, then mark the invitation accepted:
{:ok, _membership} = MyApp.Teams.create_membership(invitation.team, user, %{role: :member})
{:ok, _invitation} =
MyApp.Teams.update_invitation(invitation, %{
accepted_at: DateTime.utc_now() |> DateTime.truncate(:second)
})
/users/log-in. To make it
one-click, pass a signed token in the URL and verify it on the acceptance page.Invitation schema has a declined_at field — set it via
update_invitation/2 instead of creating a membership.from address in invitation_notifier.ex.list_invitations_for_user/1 after
sign-in and calls create_membership/3.MyApp.Mailer is configured (inherited from the base app).