File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,21 @@ defmodule Phoenix.Ecto.SQL.Sandbox do
125125 end
126126 end
127127
128+ If you have `on_mount` hooks in `live_session` defined in your `router.ex`
129+ (for example, routes requiring authentication after running `mix phx.gen.auth`
130+ to generate your authentication system), make sure the `MyApp.LiveAcceptance`
131+ hook runs before, so following hooks have access to the Ecto Sandbox:
132+
133+ live_session :require_authenticated_user,
134+ on_mount:
135+ if(Application.compile_env(:your_app, :sql_sandbox),
136+ do: [MyAppWeb.AcceptanceHook],
137+ else: []
138+ ) ++ [{MyAppWeb.UserAuth, :ensure_authenticated}] do
139+ live "/users/settings", UserSettingsLive, :edit
140+ live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
141+ end
142+
128143 ## Concurrent end-to-end tests with external clients
129144
130145 Concurrent and transactional tests for external HTTP clients is supported,
You can’t perform that action at this time.
0 commit comments