diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/content_page/[uid]/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/content_page/[uid]/page.tsx index 48cda3ccd..88fc958f7 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/content_page/[uid]/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/content_page/[uid]/page.tsx @@ -5,10 +5,9 @@ import { overview } from "@/constants/routes/myPages" import { isSignupPage } from "@/constants/routes/signup" import { env } from "@/env/server" -import { auth } from "@/auth" import ContentPage from "@/components/ContentType/StaticPages/ContentPage" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" export { generateMetadata } from "@/utils/generateMetadata" @@ -22,8 +21,9 @@ export default async function ContentPagePage() { notFound() } - const session = await auth() - if (isValidSession(session)) { + const isLoggedIn = await isLoggedInUser() + + if (isLoggedIn) { redirect(overview[lang]) } } diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx index 7482de5a0..963d3c70e 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/my-stay/page.tsx @@ -15,7 +15,6 @@ import { getSavedPaymentCardsSafely, } from "@/lib/trpc/memoizedRequests" -import { auth } from "@/auth" import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm" import accessBooking, { ACCESS_GRANTED, @@ -34,9 +33,9 @@ import Image from "@/components/Image" import { getIntl } from "@/i18n" import { setLang } from "@/i18n/serverContext" import MyStayProvider from "@/providers/MyStay" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import * as maskValue from "@/utils/maskValue" import { parseRefId } from "@/utils/refId" -import { isValidSession } from "@/utils/session" import { getCurrentWebUrl } from "@/utils/url" import Tracking from "./tracking" @@ -64,8 +63,7 @@ export default async function MyStay({ return notFound() } - const session = await auth() - const isLoggedIn = isValidSession(session) + const isLoggedIn = await isLoggedInUser() const bv = cookies().get("bv")?.value let bookingConfirmation diff --git a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx b/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx index 751fff1a8..4594c48b4 100644 --- a/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx +++ b/apps/scandic-web/app/[lang]/webview/hotelreservation/my-stay/page.tsx @@ -15,7 +15,6 @@ import { getSavedPaymentCardsSafely, } from "@/lib/trpc/memoizedRequests" -import { auth } from "@/auth" import AdditionalInfoForm from "@/components/HotelReservation/FindMyBooking/AdditionalInfoForm" import accessBooking, { ACCESS_GRANTED, @@ -34,9 +33,9 @@ import Image from "@/components/Image" import { getIntl } from "@/i18n" import { setLang } from "@/i18n/serverContext" import MyStayProvider from "@/providers/MyStay" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import * as maskValue from "@/utils/maskValue" import { parseRefId } from "@/utils/refId" -import { isValidSession } from "@/utils/session" import { getCurrentWebUrl } from "@/utils/url" import Tracking from "./tracking" @@ -65,8 +64,7 @@ export default async function MyStay({ return notFound() } - const session = await auth() - const isLoggedIn = isValidSession(session) + const isLoggedIn = await isLoggedInUser() const bv = cookies().get("bv")?.value let bookingConfirmation diff --git a/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx b/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx index 1c62dd2b4..922e007bf 100644 --- a/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx +++ b/apps/scandic-web/components/Blocks/JoinScandicFriends/index.tsx @@ -1,13 +1,12 @@ import SurpriseIcon from "@scandic-hotels/design-system/Icons/SurpriseIcon" -import { auth } from "@/auth" import Image from "@/components/Image" import Button from "@/components/TempDesignSystem/Button" import Link from "@/components/TempDesignSystem/Link" import BiroScript from "@/components/TempDesignSystem/Text/BiroScript" import Body from "@/components/TempDesignSystem/Text/Body" import Title from "@/components/TempDesignSystem/Text/Title" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import styles from "./joinScandicFriends.module.css" @@ -20,8 +19,7 @@ interface JoinScandicFriendsProps { export default async function JoinScandicFriends({ content, }: JoinScandicFriendsProps) { - const session = await auth() - const isLoggedIn = isValidSession(session) + const isLoggedIn = await isLoggedInUser() if (isLoggedIn) { return null } diff --git a/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/AuthCard/index.tsx b/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/AuthCard/index.tsx index 62a49157b..b7282ee1c 100644 --- a/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/AuthCard/index.tsx +++ b/apps/scandic-web/components/DigitalTeamMemberCard/EmployeeBenefits/AuthCard/index.tsx @@ -1,21 +1,21 @@ import { login } from "@/constants/routes/handleAuth" import { signup } from "@/constants/routes/signup" -import { auth } from "@/auth" import Card from "@/components/TempDesignSystem/Card" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import styles from "./authCard.module.css" export default async function EmployeeBenefitsAuthCard() { - const session = await auth() const intl = await getIntl() const lang = getLang() - if (isValidSession(session)) { + const isLoggedIn = await isLoggedInUser() + + if (isLoggedIn) { return null } diff --git a/apps/scandic-web/components/Header/MainMenu/MobileMenuWrapper/index.tsx b/apps/scandic-web/components/Header/MainMenu/MobileMenuWrapper/index.tsx index 3ee75f974..6e2e2b793 100644 --- a/apps/scandic-web/components/Header/MainMenu/MobileMenuWrapper/index.tsx +++ b/apps/scandic-web/components/Header/MainMenu/MobileMenuWrapper/index.tsx @@ -1,7 +1,6 @@ import { getHeader } from "@/lib/trpc/memoizedRequests" -import { auth } from "@/auth" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import MobileMenu from "../MobileMenu" @@ -10,17 +9,15 @@ export default async function MobileMenuWrapper({ }: React.PropsWithChildren) { // preloaded const header = await getHeader() - const session = await auth() if (!header) { return null } + const isLoggedIn = await isLoggedInUser() + return ( - + {children} ) diff --git a/apps/scandic-web/components/Header/TopMenu/index.tsx b/apps/scandic-web/components/Header/TopMenu/index.tsx index 3c662ad14..a5ef0cfb2 100644 --- a/apps/scandic-web/components/Header/TopMenu/index.tsx +++ b/apps/scandic-web/components/Header/TopMenu/index.tsx @@ -5,14 +5,13 @@ import { import { env } from "@/env/server" import { getHeader } from "@/lib/trpc/memoizedRequests" -import { auth } from "@/auth" import { IconName } from "@/components/Icons/iconName" import LanguageSwitcher from "@/components/LanguageSwitcher" import SkeletonShimmer from "@/components/SkeletonShimmer" import Caption from "@/components/TempDesignSystem/Text/Caption" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import { getCurrentWebUrl } from "@/utils/url" import HeaderLink from "../HeaderLink" @@ -25,8 +24,7 @@ export default async function TopMenu() { const intl = await getIntl() // both preloaded const header = await getHeader() - const session = await auth() - const isLoggedIn = isValidSession(session) + const isLoggedIn = await isLoggedInUser() if (!header) { return null diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/index.tsx index 079248673..29dccd08e 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Payment/index.tsx @@ -1,7 +1,6 @@ import { getSavedPaymentCardsSafely } from "@/lib/trpc/memoizedRequests" -import { auth } from "@/auth" -import { isValidSession } from "@/utils/session" +import { isLoggedInUser } from "@/utils/isLoggedInUser" import PaymentClient from "./PaymentClient" @@ -14,8 +13,7 @@ export default async function Payment({ const savedCreditCards = await getSavedPaymentCardsSafely({ supportedCards, }) - const session = await auth() - const isUserLoggedIn = isValidSession(session) + const isUserLoggedIn = await isLoggedInUser() return ( { + const session = await auth() + const cookie = cookies() + const webviewTokenCookie = cookie.get("webviewToken") + + // We assume we have a valid session if we have a webviewTokenCookie. + return isValidSession(session) || !!webviewTokenCookie?.value +}