Fixed auth not remembering user is logged in.

This commit is contained in:
Tom Butcher 2025-11-17 18:44:42 +00:00
parent 48631c98c3
commit caa67cd111

View File

@ -83,6 +83,11 @@ const AuthProvider = ({ children }) => {
// Read token from cookies if present
useEffect(() => {
try {
console.log(
'Retreiving token from cookies...',
getAuthCookies(),
validateAuthCookies()
)
// First validate existing cookies to clean up expired ones
if (validateAuthCookies()) {
const {
@ -210,7 +215,11 @@ const AuthProvider = ({ children }) => {
setUserProfile(authData)
// Store in cookies for persistence between tabs
const cookieSuccess = setAuthCookies(authData)
const cookieSuccess = setAuthCookies({
user: authData,
access_token: authData.access_token,
expires_at: authData.expires_at
})
if (!cookieSuccess) {
messageApi.warning(
'Authentication successful but failed to save login state. You may need to log in again if you close this tab.'