Skip to content

Commit

Permalink
check user field in scope
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Mar 6, 2025
1 parent af2f76a commit d44722b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions priv/templates/phx.gen.auth/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d44722b

Please sign in to comment.