Merged in fix/SW-2631-check-session-expiry (pull request #2004)

fix(SW-2631): check if session is valid otherwise use service token

* fix: check if session is valid otherwise use service token

* fix: only use service token for queries and updated mutations to check for valid user token


Approved-by: Michael Zetterberg
This commit is contained in:
Tobias Johansson
2025-05-08 09:20:48 +00:00
parent 15a899f48b
commit 194a401a56
3 changed files with 96 additions and 27 deletions

View File

@@ -16,6 +16,7 @@ import { auth } from "@/auth"
import HandleErrorCallback from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleErrorCallback"
import HandleSuccessCallback from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/HandleSuccessCallback"
import { encrypt } from "@/utils/encryption"
import { isValidSession } from "@/utils/session"
import type { LangParams, PageArgs } from "@/types/params"
@@ -41,7 +42,7 @@ export default async function PaymentCallbackPage({
let token = ""
const session = await auth()
if (session) {
if (isValidSession(session)) {
token = session.token.access_token
} else {
const serviceToken = await getServiceToken()