feat(WEB-132): add middlewares, support for seamless login and improve lang based routes

This commit is contained in:
Michael Zetterberg
2024-04-08 16:08:35 +02:00
parent 8ab5325fc3
commit 7093a0b2dd
31 changed files with 493 additions and 188 deletions

View File

@@ -1,6 +1,4 @@
import { redirect } from "next/navigation"
import { auth } from "@/auth"
import { auth, signIn } from "@/auth"
import type { LangParams, LayoutArgs } from "@/types/params"
@@ -14,7 +12,10 @@ export default async function ProtectedLayout({
* protected route group is actually protected.
*/
if (!session) {
return redirect(`/${params.lang}/login`)
await signIn("curity", undefined, {
ui_locales: params.lang,
})
return null
}
return <>{children}</>