@ -12,6 +12,7 @@
export function useAuth() {
export function useAuth() {
const { loggedIn , user , clear , fetch } = useUserSession ( )
const { loggedIn , user , clear , fetch } = useUserSession ( )
const { fetchRoleStatus } = useActiveRole ( )
const { fetchRoleStatus } = useActiveRole ( )
const { fetchCart } = useCart ( )
/ * *
/ * *
* Login with email and password
* Login with email and password
@ -41,6 +42,9 @@ export function useAuth() {
// Fetch user roles immediately after login
// Fetch user roles immediately after login
await fetchRoleStatus ( )
await fetchRoleStatus ( )
// Refresh cart after login to show any existing items
await fetchCart ( )
// Redirect to products page or saved destination
// Redirect to products page or saved destination
const redirectAfterLogin = useCookie ( 'redirect_after_login' )
const redirectAfterLogin = useCookie ( 'redirect_after_login' )
const destination = redirectAfterLogin . value || '/'
const destination = redirectAfterLogin . value || '/'