Merged in feat/loy-403-seamless (pull request #3164)
feat(LOY-403): removed seamless login/logout * feat(LOY-403): removed seamless login/logout Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
import { type NextMiddleware, NextResponse } from "next/server"
|
||||
|
||||
import { badRequest } from "@/server/errors/next"
|
||||
|
||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||
|
||||
import type { MiddlewareMatcher } from "@/types/middleware"
|
||||
|
||||
export const middleware: NextMiddleware = (request) => {
|
||||
const returnUrl = request.nextUrl.searchParams.get("returnurl")
|
||||
|
||||
if (!returnUrl) {
|
||||
return badRequest()
|
||||
}
|
||||
|
||||
const lang = findLang(request.nextUrl.pathname)!
|
||||
|
||||
const headers = new Headers(request.headers)
|
||||
headers.set("x-returnurl", returnUrl)
|
||||
headers.set("x-login-source", "seamless")
|
||||
|
||||
return NextResponse.rewrite(new URL(`/${lang}/login`, request.nextUrl), {
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const matcher: MiddlewareMatcher = (request) => {
|
||||
return request.nextUrl.pathname.endsWith("/updatelogin")
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { type NextMiddleware, NextResponse } from "next/server"
|
||||
|
||||
import { badRequest } from "@/server/errors/next"
|
||||
|
||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||
|
||||
import type { MiddlewareMatcher } from "@/types/middleware"
|
||||
|
||||
export const middleware: NextMiddleware = (request) => {
|
||||
const returnUrl = request.nextUrl.searchParams.get("returnurl")
|
||||
|
||||
if (!returnUrl) {
|
||||
return badRequest()
|
||||
}
|
||||
|
||||
const lang = findLang(request.nextUrl.pathname)!
|
||||
|
||||
const headers = new Headers(request.headers)
|
||||
headers.set("x-returnurl", returnUrl)
|
||||
headers.set("x-login-source", "seamless-magiclink")
|
||||
|
||||
return NextResponse.rewrite(new URL(`/${lang}/login`, request.nextUrl), {
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const matcher: MiddlewareMatcher = (request) => {
|
||||
return request.nextUrl.pathname.endsWith("/updateloginemail")
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { type NextMiddleware, NextResponse } from "next/server"
|
||||
|
||||
import { badRequest } from "@/server/errors/next"
|
||||
import { getPublicURL } from "@/server/utils"
|
||||
|
||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||
|
||||
import type { MiddlewareMatcher } from "@/types/middleware"
|
||||
|
||||
export const middleware: NextMiddleware = (request) => {
|
||||
const currentwebUrl = request.nextUrl.searchParams.get("currentweb")
|
||||
if (currentwebUrl == null || undefined) {
|
||||
return badRequest()
|
||||
}
|
||||
const lang = findLang(request.nextUrl.pathname)!
|
||||
|
||||
const redirectTo = getPublicURL(request)
|
||||
|
||||
const headers = new Headers(request.headers)
|
||||
headers.set("x-returnurl", redirectTo)
|
||||
headers.set("x-logout-source", "seamless")
|
||||
|
||||
return NextResponse.rewrite(new URL(`/${lang}/logout`, request.nextUrl), {
|
||||
request: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
export const matcher: MiddlewareMatcher = (request) => {
|
||||
return request.nextUrl.pathname.endsWith("/updatelogout")
|
||||
}
|
||||
Reference in New Issue
Block a user