Fix null checks for user and CIO cookie in event handling
- Updated the condition to safely check for the presence of user data in event.locals, preventing potential runtime errors when accessing nested properties.
This commit is contained in:
@@ -32,7 +32,7 @@ const handlePagesRoutes: Handle = async ({ event, resolve }) => {
|
||||
return resolve(event);
|
||||
}
|
||||
|
||||
if (!event.locals.user && !hasCioCookie) {
|
||||
if (!event?.locals?.user && !hasCioCookie) {
|
||||
console.log('no user and no cio cookie, redirecting to login');
|
||||
const shouldAddRedirectParam = !pathname.includes(ROUTE.LOGOUT);
|
||||
const fullPath = pathname + event.url.search;
|
||||
|
||||
Reference in New Issue
Block a user