feat: SW-1583 Used constants for strings

This commit is contained in:
Hrishikesh Vaipurkar
2025-03-06 16:23:16 +01:00
parent 23eaa772ea
commit 24bf96df41
12 changed files with 55 additions and 35 deletions

View File

@@ -1,20 +1,20 @@
import { NextResponse } from "next/server"
import { type NextMiddleware,NextResponse } from "next/server"
import { REDEMPTION, SEARCHTYPE } from "@/constants/booking"
import { login } from "@/constants/routes/handleAuth"
import { getPublicNextURL } from "@/server/utils"
import { auth } from "@/auth"
import { findLang } from "@/utils/languages"
import { getDefaultRequestHeaders } from "./utils"
import type { NextMiddleware } from "next/server"
import type { MiddlewareMatcher } from "@/types/middleware"
import { auth } from "@/auth"
import { getPublicNextURL } from "@/server/utils"
import { login } from "@/constants/routes/handleAuth"
import { findLang } from "@/utils/languages"
export const middleware: NextMiddleware = async (request) => {
// Redirect user to login if reward nights search and not logged in
const isRedemption =
request.nextUrl.searchParams.get("searchtype") === "redemption" ||
request.nextUrl.searchParams.get("searchType") === "redemption"
request.nextUrl.searchParams.get(SEARCHTYPE) === REDEMPTION
const session = await auth() // Check for user session
if (isRedemption && (!session || session?.error)) {
const lang = findLang(request.nextUrl.pathname)!