🔒️ Redirect anonymous user to login for event options page
Tim Izzo tim@octree.ch
Wed, 15 Jan 2025 15:44:34 +0100
1 files changed,
10 insertions(+),
1 deletions(-)
M
frontend/pages/e/[uuid]/prices.tsx
→
frontend/pages/e/[uuid]/prices.tsx
@@ -9,7 +9,7 @@ import EventLayout, {TabComponent} from '../../../layouts/Event';
import useEventStore from '../../../stores/useEventStore'; import {Box, Container, Paper, useTheme} from '@mui/material'; import Head from 'next/head'; -import {useSession} from 'next-auth/react'; +import {getSession, useSession} from 'next-auth/react'; import pageUtils from '../../../lib/pageUtils'; import {getLocaleForLang} from '../../../lib/getLocale';@@ -72,6 +72,15 @@ const {uuid} = context.query;
const {host = ''} = context.req.headers; let event = null; let modulesSettings = null; + + const session = await getSession(context); + if (!session) + return { + redirect: { + destination: `/auth/login?redirectPath=${context.resolvedUrl}`, + permanent: false, + }, + }; // Fetch event try {