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:
@@ -31,6 +31,7 @@ export const bookingQueryRouter = router({
|
||||
.concat(refIdPlugin.toConfirmationNumber)
|
||||
.use(async ({ ctx, input, next }) => {
|
||||
const lang = input.lang ?? ctx.lang
|
||||
|
||||
return next({
|
||||
ctx: {
|
||||
lang,
|
||||
@@ -88,7 +89,6 @@ export const bookingQueryRouter = router({
|
||||
}),
|
||||
findBooking: safeProtectedServiceProcedure
|
||||
.input(findBookingInput)
|
||||
|
||||
.query(async function ({
|
||||
ctx,
|
||||
input: { confirmationNumber, lastName, firstName, email },
|
||||
@@ -151,16 +151,14 @@ export const bookingQueryRouter = router({
|
||||
.concat(refIdPlugin.toConfirmationNumber)
|
||||
.use(async ({ ctx, input, next }) => {
|
||||
const lang = input.lang ?? ctx.lang
|
||||
const token = ctx.session?.token.access_token ?? ctx.serviceToken
|
||||
return next({
|
||||
ctx: {
|
||||
lang,
|
||||
token,
|
||||
},
|
||||
})
|
||||
})
|
||||
.query(async function ({ ctx }) {
|
||||
const { confirmationNumber, lang, token } = ctx
|
||||
const { confirmationNumber, lang, serviceToken } = ctx
|
||||
|
||||
const getLinkedReservationsCounter = createCounter(
|
||||
"trpc.booking",
|
||||
@@ -172,7 +170,7 @@ export const bookingQueryRouter = router({
|
||||
|
||||
metricsGetLinkedReservations.start()
|
||||
|
||||
const booking = await getBooking(confirmationNumber, lang, token)
|
||||
const booking = await getBooking(confirmationNumber, lang, serviceToken)
|
||||
|
||||
if (!booking) {
|
||||
return []
|
||||
@@ -180,7 +178,7 @@ export const bookingQueryRouter = router({
|
||||
|
||||
const linkedReservationsResults = await Promise.allSettled(
|
||||
booking.linkedReservations.map((linkedReservation) =>
|
||||
getBooking(linkedReservation.confirmationNumber, lang, token)
|
||||
getBooking(linkedReservation.confirmationNumber, lang, serviceToken)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user