chore: add back language specific routes
This commit is contained in:
@@ -26,4 +26,9 @@ SEAMLESS_LOGIN_EN="http://www.example.com/updatelogin"
|
||||
SEAMLESS_LOGIN_FI="http://www.example.fi/updatelogin"
|
||||
SEAMLESS_LOGIN_NO="http://www.example.no/updatelogin"
|
||||
SEAMLESS_LOGIN_SV="http://www.example.se/updatelogin"
|
||||
SEAMLESS_LOGOUT="http://www.example.com/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_DA="http://www.example.dk/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_DE="http://www.example.de/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_EN="http://www.example.com/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_FI="http://www.example.fi/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_NO="http://www.example.no/updatelogout?newweb"
|
||||
SEAMLESS_LOGOUT_SV="http://www.example.sv/updatelogout?newweb"
|
||||
|
||||
@@ -3,19 +3,22 @@ import { headers as nextHeaders } from "next/headers"
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { AuthError } from "next-auth"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
import { env } from "@/env/server"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
import { internalServerError } from "@/server/errors/next"
|
||||
|
||||
import { signOut } from "@/auth"
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: { lang: Lang } }
|
||||
) {
|
||||
let redirectHeaders: Headers | undefined = undefined
|
||||
let redirectTo: string
|
||||
|
||||
const returnUrl = request.headers.get("x-returnurl")
|
||||
console.log("TESTING", returnUrl)
|
||||
if (returnUrl) {
|
||||
// Should check for ?currentweb in header?
|
||||
redirectTo = returnUrl
|
||||
} else {
|
||||
// Normal logout request from New web
|
||||
@@ -40,7 +43,28 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
try {
|
||||
// Initiate the seamless logout flow
|
||||
const redirectUrl = new URL(env.SEAMLESS_LOGOUT)
|
||||
let redirectUrlValue
|
||||
switch (context.params.lang) {
|
||||
case Lang.da:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_DA
|
||||
break
|
||||
case Lang.de:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_DE
|
||||
break
|
||||
case Lang.en:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_EN
|
||||
break
|
||||
case Lang.fi:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_FI
|
||||
break
|
||||
case Lang.no:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_NO
|
||||
break
|
||||
case Lang.sv:
|
||||
redirectUrlValue = env.SEAMLESS_LOGOUT_SV
|
||||
break
|
||||
}
|
||||
const redirectUrl = new URL(redirectUrlValue)
|
||||
redirectUrl.searchParams.set("returnurl", redirectTo)
|
||||
redirectTo = redirectUrl.toString()
|
||||
} catch (e) {
|
||||
|
||||
14
env/server.ts
vendored
14
env/server.ts
vendored
@@ -48,7 +48,12 @@ export const env = createEnv({
|
||||
SEAMLESS_LOGIN_FI: z.string(),
|
||||
SEAMLESS_LOGIN_NO: z.string(),
|
||||
SEAMLESS_LOGIN_SV: z.string(),
|
||||
SEAMLESS_LOGOUT: z.string(),
|
||||
SEAMLESS_LOGOUT_DA: z.string(),
|
||||
SEAMLESS_LOGOUT_DE: z.string(),
|
||||
SEAMLESS_LOGOUT_EN: z.string(),
|
||||
SEAMLESS_LOGOUT_FI: z.string(),
|
||||
SEAMLESS_LOGOUT_NO: z.string(),
|
||||
SEAMLESS_LOGOUT_SV: z.string(),
|
||||
WEBVIEW_ENCRYPTION_KEY: z.string(),
|
||||
},
|
||||
emptyStringAsUndefined: true,
|
||||
@@ -83,7 +88,12 @@ export const env = createEnv({
|
||||
SEAMLESS_LOGIN_FI: process.env.SEAMLESS_LOGIN_FI,
|
||||
SEAMLESS_LOGIN_NO: process.env.SEAMLESS_LOGIN_NO,
|
||||
SEAMLESS_LOGIN_SV: process.env.SEAMLESS_LOGIN_SV,
|
||||
SEAMLESS_LOGOUT: process.env.SEAMLESS_LOGOUT,
|
||||
SEAMLESS_LOGOUT_DA: process.env.SEAMLESS_LOGOUT_DA,
|
||||
SEAMLESS_LOGOUT_DE: process.env.SEAMLESS_LOGOUT_DE,
|
||||
SEAMLESS_LOGOUT_EN: process.env.SEAMLESS_LOGOUT_EN,
|
||||
SEAMLESS_LOGOUT_FI: process.env.SEAMLESS_LOGOUT_FI,
|
||||
SEAMLESS_LOGOUT_NO: process.env.SEAMLESS_LOGOUT_NO,
|
||||
SEAMLESS_LOGOUT_SV: process.env.SEAMLESS_LOGOUT_SV,
|
||||
WEBVIEW_ENCRYPTION_KEY: process.env.WEBVIEW_ENCRYPTION_KEY,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user