chore(debug): auth
This commit is contained in:
7
app/[lang]/(live)/(protected)/bypass/page.tsx
Normal file
7
app/[lang]/(live)/(protected)/bypass/page.tsx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { auth } from "@/auth"
|
||||||
|
|
||||||
|
export default async function ByPass() {
|
||||||
|
const session = await auth()
|
||||||
|
|
||||||
|
return <pre>{JSON.stringify(session, null, 2)}</pre>
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { auth, signIn } from "@/auth"
|
import { redirect } from "next/navigation"
|
||||||
|
|
||||||
|
import { auth } from "@/auth"
|
||||||
|
|
||||||
import type { LangParams, LayoutArgs } from "@/types/params"
|
import type { LangParams, LayoutArgs } from "@/types/params"
|
||||||
|
|
||||||
@@ -12,10 +14,7 @@ export default async function ProtectedLayout({
|
|||||||
* protected route group is actually protected.
|
* protected route group is actually protected.
|
||||||
*/
|
*/
|
||||||
if (!session) {
|
if (!session) {
|
||||||
await signIn("curity", undefined, {
|
redirect(`/${params.lang}/login`)
|
||||||
ui_locales: params.lang,
|
|
||||||
})
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
|
|||||||
@@ -47,38 +47,38 @@ export async function GET(
|
|||||||
"redirectTo=; Expires=Thu, 01 Jan 1970 00:00:00 UTC; Path=/; HttpOnly; SameSite=Lax"
|
"redirectTo=; Expires=Thu, 01 Jan 1970 00:00:00 UTC; Path=/; HttpOnly; SameSite=Lax"
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
// Initiate the seamless login flow
|
// // Initiate the seamless login flow
|
||||||
let redirectUrlValue
|
// let redirectUrlValue
|
||||||
switch (context.params.lang) {
|
// switch (context.params.lang) {
|
||||||
case Lang.da:
|
// case Lang.da:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_DA
|
// redirectUrlValue = env.SEAMLESS_LOGIN_DA
|
||||||
break
|
// break
|
||||||
case Lang.de:
|
// case Lang.de:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_DE
|
// redirectUrlValue = env.SEAMLESS_LOGIN_DE
|
||||||
break
|
// break
|
||||||
case Lang.en:
|
// case Lang.en:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_EN
|
// redirectUrlValue = env.SEAMLESS_LOGIN_EN
|
||||||
break
|
// break
|
||||||
case Lang.fi:
|
// case Lang.fi:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_FI
|
// redirectUrlValue = env.SEAMLESS_LOGIN_FI
|
||||||
break
|
// break
|
||||||
case Lang.no:
|
// case Lang.no:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_NO
|
// redirectUrlValue = env.SEAMLESS_LOGIN_NO
|
||||||
break
|
// break
|
||||||
case Lang.sv:
|
// case Lang.sv:
|
||||||
redirectUrlValue = env.SEAMLESS_LOGIN_SV
|
// redirectUrlValue = env.SEAMLESS_LOGIN_SV
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
const redirectUrl = new URL(redirectUrlValue)
|
// const redirectUrl = new URL(redirectUrlValue)
|
||||||
redirectUrl.searchParams.set("returnurl", redirectTo)
|
// redirectUrl.searchParams.set("returnurl", redirectTo)
|
||||||
redirectTo = redirectUrl.toString()
|
// redirectTo = redirectUrl.toString()
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
console.error(
|
// console.error(
|
||||||
"Unable to create URL for seamless login, proceeding without it."
|
// "Unable to create URL for seamless login, proceeding without it."
|
||||||
)
|
// )
|
||||||
console.error(e)
|
// console.error(e)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -101,6 +101,7 @@ export async function GET(
|
|||||||
)
|
)
|
||||||
console.log({ login_signInURL: signInURL })
|
console.log({ login_signInURL: signInURL })
|
||||||
|
|
||||||
|
console.log({ login_redirectTo: redirectTo })
|
||||||
const redirectUrl = await signIn(
|
const redirectUrl = await signIn(
|
||||||
"curity",
|
"curity",
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user