You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also use this to prevent users from visiting the auto generated sign_in route: sign_in_route(on_mount: [{MyAppWeb.LiveUserAuth, :live_no_user}])
defmoduleMyAppWeb.LiveUserAuthdo@moduledoc""" Helpers for authenticating users in LiveViews. """importPhoenix.ComponentuseMyAppWeb,:verified_routes# the rest of the functions defon_mount(:live_no_user,_params,_session,socket)dodbg(socket.assigns)ifsocket.assigns[:current_user]do{:halt,Phoenix.LiveView.redirect(socket,to: ~p"/")}else{:cont,assign(socket,:current_user,nil)}endendend
But current_user is never set in the socket.assigns, whether a user is logged in or not.
The guide for Ash authentication w/ LiveView mentions:
I've added this in my app:
With the
MyAppWeb.LiveUserAuth
module -But
current_user
is never set in thesocket.assigns
, whether a user is logged in or not.So a user can still visit the sign-in page, even when already signed in.
The text was updated successfully, but these errors were encountered: