feat(SW-158): Optimized code

This commit is contained in:
Hrishikesh Vaipurkar
2024-08-15 11:05:17 +02:00
parent 710730a9e9
commit fd4c238428

View File

@@ -13,10 +13,11 @@ export async function GET(
context: { params: { lang: Lang } }
) {
let redirectTo: string
let loginKey: string | null
// Set callback from Cookie set by NextAuth when intiating login
redirectTo = request.cookies.get("Scandic-auth.callback-url")?.value || "/"
redirectTo =
request.cookies.get("Scandic-auth.callback-url")?.value ||
"/" + context.params.lang
// Make relative URL to absolute URL
if (redirectTo.startsWith("/")) {
@@ -26,17 +27,10 @@ export async function GET(
redirectTo = new URL(redirectTo, env.PUBLIC_URL).href
}
// Remove Seamless login as it doesn't work with Magic link login due to different authenticators
// if (redirectTo.indexOf("updatelogin?returnurl") !== -1) {
// // Additional URL decode required as url in the query parameter is encoded twice as
// // passed in query param and further in cookie value.
// redirectTo = decodeURIComponent(
// redirectTo.substring(redirectTo.indexOf("returnurl") + 10)
// )
// }
// Update Seamless login url as Magic link login has a different authenticator in Curity
redirectTo = redirectTo.replace("updatelogin", "updateloginemail")
loginKey = request.nextUrl.searchParams.get("loginKey")
const loginKey = request.nextUrl.searchParams.get("loginKey")
if (!loginKey) {
if (!env.PUBLIC_URL) {