Sigra.EmailTemplates behaviour (Sigra v1.20.0)

Copy Markdown View Source

Behaviour for generated email template modules.

The generated MyApp.Auth.Emails module implements this behaviour. Each callback builds a map with :to, :subject, and :body keys that can be delivered via Sigra.Delivery.

Security Notification Emails

These templates are called by the library layer inside Auth.authenticate/2 to ensure security notifications are always sent, regardless of how the developer's generated code calls authenticate.

Summary

Callbacks

Build an API token created notification email.

Build a confirmation email.

Build deletion cancelled confirmation email.

Build deletion finalized notification email.

Build deletion scheduled notification email.

Build email change confirmation email to new address.

Build email change notification email to old address.

Build post-email-change confirmation email to new address.

Build an account lockout notification email.

Build a magic link email.

Build password change notification email.

Build a password reset email.

Build a suspicious login notification email.

Callbacks

api_token_created_email(user, token)

(since 0.7.0)
@callback api_token_created_email(user :: struct(), token :: struct()) :: map()

Build an API token created notification email.

confirmation_email(user, url, code)

(since 0.3.0)
@callback confirmation_email(user :: struct(), url :: String.t(), code :: String.t()) ::
  map()

Build a confirmation email.

deletion_cancelled_email(user, login_url)

(since 0.8.0)
@callback deletion_cancelled_email(user :: struct(), login_url :: String.t()) :: map()

Build deletion cancelled confirmation email.

deletion_finalized_email(email)

(since 0.8.0)
@callback deletion_finalized_email(email :: String.t()) :: map()

Build deletion finalized notification email.

deletion_scheduled_email(user, scheduled_date, cancel_url)

(since 0.8.0)
@callback deletion_scheduled_email(
  user :: struct(),
  scheduled_date :: DateTime.t(),
  cancel_url :: String.t()
) :: map()

Build deletion scheduled notification email.

email_change_confirmation_email(user, new_email, url)

(since 0.8.0)
@callback email_change_confirmation_email(
  user :: struct(),
  new_email :: String.t(),
  url :: String.t()
) :: map()

Build email change confirmation email to new address.

email_change_notification_email(user, new_email, cancel_url)

(since 0.8.0)
@callback email_change_notification_email(
  user :: struct(),
  new_email :: String.t(),
  cancel_url :: String.t()
) :: map()

Build email change notification email to old address.

email_changed_email(user)

(since 0.8.0)
@callback email_changed_email(user :: struct()) :: map()

Build post-email-change confirmation email to new address.

lockout_notification_email(user, details)

(since 0.4.0)
@callback lockout_notification_email(user :: struct(), details :: map()) :: map()

Build an account lockout notification email.

password_changed_email(user, details)

(since 0.8.0)
@callback password_changed_email(user :: struct(), details :: map()) :: map()

Build password change notification email.

reset_password_email(user, url)

(since 0.3.0)
@callback reset_password_email(user :: struct(), url :: String.t()) :: map()

Build a password reset email.

suspicious_login_email(user, details)

(since 0.4.0)
@callback suspicious_login_email(user :: struct(), details :: map()) :: map()

Build a suspicious login notification email.