Closed michaelprys closed 1 month ago
how to update the UI immediately after logging in without needing a page refresh.
Just call useUserSession().fetch()
to refresh the session on the frontend.
the differences between ready and loggedIn and which one to use to conditionally display elements like 'sign out' button? To me they seem like a same thing, but ready is for some reason always true.
Don't use ready
as this is internal
how to properly handle cookie removal and its effect on the login state.
This is the behavior from H3 and it is fine to have an empty cookie as long as the session tells you that you are logged out
Thank you for the detailed answer! Works like a charm.
I'm having issues with user authentication:
ready
is alwaystrue
. This property remainstrue
even when the cookie is missing.loggedIn
doesn't update in real-time. After logging in, I see the 'Error signing in' in the form and no redirect happens, becauseloggedIn
is stillfalse
, even though the cookie was created. So the only solution is to refresh the page to see that I'm logged and redirect will apply. To show the 'sign out' instead ofsign in
I will also needloggedIn
to betrue
.clear()
method, it only sets thevalue
in devtools Application to an empty string instead of completely removing it. I can still see 'nuxt-cookie' in the developer tools. Is it how it's supposed to work or is it a bug?I would really appreciate the help with:
ready
andloggedIn
and which one to use to conditionally display elements like 'sign out' button? To me they seem like a same thing, butready
is for some reason alwaystrue
.I'm looking for a possible solution.