From d44722b715a4c8803b8aeba908436739acf15ba9 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Thu, 6 Mar 2025 20:58:32 +0100 Subject: [PATCH] check user field in scope --- priv/templates/phx.gen.auth/auth.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/phx.gen.auth/auth.ex b/priv/templates/phx.gen.auth/auth.ex index 6244bb9e49..1a716fbcd9 100644 --- a/priv/templates/phx.gen.auth/auth.ex +++ b/priv/templates/phx.gen.auth/auth.ex @@ -160,7 +160,7 @@ defmodule <%= inspect auth_module %> do def on_mount(:ensure_authenticated, _params, session, socket) do socket = mount_current_scope(socket, session) - if socket.assigns.current_scope do + if socket.assigns.current_scope && socket.assigns.current_scope.<%= schema.singular %> do {:cont, socket} else socket = @@ -233,7 +233,7 @@ defmodule <%= inspect auth_module %> do they use the application at all, here would be a good place. """ def require_authenticated_<%= schema.singular %>(conn, _opts) do - if conn.assigns.current_scope do + if conn.assigns.current_scope && conn.assigns.current_scope.<%= schema.singular %> do conn else conn