mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
Add user accounts, roles, and admin gating
- Scaffold password auth (email or username) with phx.gen.auth; no magic links - Add role (member/moderator/admin/super_admin) and plan (free/premium) enums - Gate /admin behind admin-or-above via plug + on_mount; hide the nav link - Add mix accounts.promote for CLI role changes - Disable email confirmation by confirming accounts at registration Closes #3
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
defmodule Chesstrainer.Accounts.UserNotifier do
|
||||
import Swoosh.Email
|
||||
|
||||
alias Chesstrainer.Mailer
|
||||
|
||||
# Delivers the email using the application mailer.
|
||||
defp deliver(recipient, subject, body) do
|
||||
email =
|
||||
new()
|
||||
|> to(recipient)
|
||||
|> from({"Chesstrainer", "contact@example.com"})
|
||||
|> subject(subject)
|
||||
|> text_body(body)
|
||||
|
||||
with {:ok, _metadata} <- Mailer.deliver(email) do
|
||||
{:ok, email}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deliver instructions to update a user email.
|
||||
"""
|
||||
def deliver_update_email_instructions(user, url) do
|
||||
deliver(user.email, "Update email instructions", """
|
||||
|
||||
==============================
|
||||
|
||||
Hi #{user.email},
|
||||
|
||||
You can change your email by visiting the URL below:
|
||||
|
||||
#{url}
|
||||
|
||||
If you didn't request this change, please ignore this.
|
||||
|
||||
==============================
|
||||
""")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user