feat: SW-158 Optimized comments

This commit is contained in:
Hrishikesh Vaipurkar
2024-07-31 15:48:04 +02:00
parent cdd83a4346
commit ce51402443
2 changed files with 7 additions and 3 deletions

View File

@@ -15,7 +15,8 @@ export async function GET(
let redirectTo: string
let loginKey: string | null
redirectTo = request.cookies.get("Scandic-auth.callback-url")?.value || "/" // Cookie gets set by NextAuth from login initiation
// Set callback from Cookie set by NextAuth when intiating login
redirectTo = request.cookies.get("Scandic-auth.callback-url")?.value || "/"
// Make relative URL to absolute URL
if (redirectTo.startsWith("/")) {
@@ -25,9 +26,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
// 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 due to passed in query param and further in cookie value.
// 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)
)

View File

@@ -192,6 +192,8 @@ export const config = {
},
},
cookies: {
// Specific cookie name required to reset callback url when login using
// Email verification link (Magic link) scenario
callbackUrl: {
name: `Scandic-auth.callback-url`,
options: {