Added middleware and session helper
This commit is contained in:
14
src/lib/auth/session.ts
Normal file
14
src/lib/auth/session.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { headers } from "next/headers"
|
||||
import { auth } from "./auth"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
export async function getSession() {
|
||||
const session = await auth.api.getSession({
|
||||
headers: await headers()
|
||||
})
|
||||
const redirectFunc = (path: string) => {
|
||||
redirect(path)
|
||||
}
|
||||
|
||||
return { session, redirect: redirectFunc }
|
||||
}
|
||||
Reference in New Issue
Block a user