mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 12:52:55 +12:00
docs: Update Confirmation Tutorial docs (#741)
* Add missing Swoosh imports * Cast email to string * Fix token vars * Add missing require_atomic * Fix copy & paste naming mistake * Change token to confirm for confirm new user url
This commit is contained in:
parent
58ee13adaf
commit
f6c2ae6267
1 changed files with 10 additions and 7 deletions
|
@ -67,10 +67,11 @@ Next we will define our "sender" module using `Swoosh`:
|
||||||
```elixir
|
```elixir
|
||||||
defmodule MyApp.NewUserConfirmationSender do
|
defmodule MyApp.NewUserConfirmationSender do
|
||||||
use AshAuthentication.Sender
|
use AshAuthentication.Sender
|
||||||
|
import Swoosh.Email
|
||||||
|
|
||||||
def send(user, token, _opts) do
|
def send(user, confirm, _opts) do
|
||||||
new()
|
new()
|
||||||
|> to(user.email)
|
|> to(to_string(user.email))
|
||||||
|> from({"MyApp Admin", "support@myapp.inc"})
|
|> from({"MyApp Admin", "support@myapp.inc"})
|
||||||
|> subject("Confirm your email address")
|
|> subject("Confirm your email address")
|
||||||
|> html_body("""
|
|> html_body("""
|
||||||
|
@ -81,7 +82,7 @@ defmodule MyApp.NewUserConfirmationSender do
|
||||||
If it was you, then please click the link below to confirm your identity. If you did not initiate this request then please ignore this email.
|
If it was you, then please click the link below to confirm your identity. If you did not initiate this request then please ignore this email.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="https://myapp.inc/auth/user/confirm_new_user?#{URI.encode_query(token: @token)}">Click here to confirm your account</a>
|
<a href="https://myapp.inc/auth/user/confirm_new_user?#{URI.encode_query(confirm: confirm)}">Click here to confirm your account</a>
|
||||||
</p>
|
</p>
|
||||||
""")
|
""")
|
||||||
|> MyApp.Mailer.deliver()
|
|> MyApp.Mailer.deliver()
|
||||||
|
@ -124,12 +125,13 @@ end
|
||||||
Next, let's define our new sender:
|
Next, let's define our new sender:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
defmodule MyApp.NewUserConfirmationSender do
|
defmodule MyApp.EmailChangeConfirmationSender do
|
||||||
use AshAuthentication.Sender
|
use AshAuthentication.Sender
|
||||||
|
import Swoosh.Email
|
||||||
|
|
||||||
def send(user, token, _opts) do
|
def send(user, token, _opts) do
|
||||||
new()
|
new()
|
||||||
|> to(user.email)
|
|> to(to_string(user.email))
|
||||||
|> from({"MyApp Admin", "support@myapp.inc"})
|
|> from({"MyApp Admin", "support@myapp.inc"})
|
||||||
|> subject("Confirm your new email address")
|
|> subject("Confirm your new email address")
|
||||||
|> html_body("""
|
|> html_body("""
|
||||||
|
@ -139,7 +141,7 @@ defmodule MyApp.NewUserConfirmationSender do
|
||||||
You recently changed your email address on <a href="https://myapp.inc">MyApp</a>. Please confirm it.
|
You recently changed your email address on <a href="https://myapp.inc">MyApp</a>. Please confirm it.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="https://myapp.inc/auth/user/confirm_change?#{URI.encode_query(token: @token)}">Click here to confirm your new email address</a>
|
<a href="https://myapp.inc/auth/user/confirm_change?#{URI.encode_query(token: token)}">Click here to confirm your new email address</a>
|
||||||
</p>
|
</p>
|
||||||
""")
|
""")
|
||||||
|> MyApp.Mailer.deliver()
|
|> MyApp.Mailer.deliver()
|
||||||
|
@ -168,7 +170,8 @@ defmodule MyApp.Accounts.User do
|
||||||
|
|
||||||
update :confirm_change do
|
update :confirm_change do
|
||||||
argument :confirm, :string, allow_nil?: false, public?: true
|
argument :confirm, :string, allow_nil?: false, public?: true
|
||||||
|
accept [:email]
|
||||||
|
require_atomic? false
|
||||||
change AshAuthentication.AddOn.Confirmation.ConfirmChange
|
change AshAuthentication.AddOn.Confirmation.ConfirmChange
|
||||||
change AshAuthentication.GenerateTokenChange
|
change AshAuthentication.GenerateTokenChange
|
||||||
change MyApp.UpdateCrmSystem, only_when_valid?: true
|
change MyApp.UpdateCrmSystem, only_when_valid?: true
|
||||||
|
|
Loading…
Reference in a new issue