feat: SW-1583 Used constants for strings
This commit is contained in:
@@ -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)!
|
||||
|
||||
Reference in New Issue
Block a user