Fixed auth not remembering user is logged in.
This commit is contained in:
parent
48631c98c3
commit
caa67cd111
@ -83,6 +83,11 @@ const AuthProvider = ({ children }) => {
|
|||||||
// Read token from cookies if present
|
// Read token from cookies if present
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
try {
|
try {
|
||||||
|
console.log(
|
||||||
|
'Retreiving token from cookies...',
|
||||||
|
getAuthCookies(),
|
||||||
|
validateAuthCookies()
|
||||||
|
)
|
||||||
// First validate existing cookies to clean up expired ones
|
// First validate existing cookies to clean up expired ones
|
||||||
if (validateAuthCookies()) {
|
if (validateAuthCookies()) {
|
||||||
const {
|
const {
|
||||||
@ -210,7 +215,11 @@ const AuthProvider = ({ children }) => {
|
|||||||
setUserProfile(authData)
|
setUserProfile(authData)
|
||||||
|
|
||||||
// Store in cookies for persistence between tabs
|
// 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) {
|
if (!cookieSuccess) {
|
||||||
messageApi.warning(
|
messageApi.warning(
|
||||||
'Authentication successful but failed to save login state. You may need to log in again if you close this tab.'
|
'Authentication successful but failed to save login state. You may need to log in again if you close this tab.'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user