feat(SW-158): Optimized code
This commit is contained in:
@@ -13,10 +13,11 @@ export async function GET(
|
|||||||
context: { params: { lang: Lang } }
|
context: { params: { lang: Lang } }
|
||||||
) {
|
) {
|
||||||
let redirectTo: string
|
let redirectTo: string
|
||||||
let loginKey: string | null
|
|
||||||
|
|
||||||
// Set callback from Cookie set by NextAuth when intiating login
|
// 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
|
// Make relative URL to absolute URL
|
||||||
if (redirectTo.startsWith("/")) {
|
if (redirectTo.startsWith("/")) {
|
||||||
@@ -26,17 +27,10 @@ export async function GET(
|
|||||||
redirectTo = new URL(redirectTo, env.PUBLIC_URL).href
|
redirectTo = new URL(redirectTo, env.PUBLIC_URL).href
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove Seamless login as it doesn't work with Magic link login due to different authenticators
|
// Update Seamless login url as Magic link login has a different authenticator in Curity
|
||||||
// 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)
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
redirectTo = redirectTo.replace("updatelogin", "updateloginemail")
|
redirectTo = redirectTo.replace("updatelogin", "updateloginemail")
|
||||||
|
|
||||||
loginKey = request.nextUrl.searchParams.get("loginKey")
|
const loginKey = request.nextUrl.searchParams.get("loginKey")
|
||||||
|
|
||||||
if (!loginKey) {
|
if (!loginKey) {
|
||||||
if (!env.PUBLIC_URL) {
|
if (!env.PUBLIC_URL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user