Atualiza portal e admin com bloqueio de máquinas desativadas
This commit is contained in:
parent
e5085962e9
commit
630110bf3a
31 changed files with 1756 additions and 244 deletions
37
src/app/api/auth/get-session/route.ts
Normal file
37
src/app/api/auth/get-session/route.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { NextResponse } from "next/server"
|
||||
|
||||
import { auth } from "@/lib/auth"
|
||||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const result = await auth.api.getSession({ headers: request.headers, request, asResponse: true })
|
||||
|
||||
if (!result) {
|
||||
return NextResponse.json({ user: null }, { status: 200 })
|
||||
}
|
||||
|
||||
const body = await result.json()
|
||||
const response = NextResponse.json(body, {
|
||||
status: result.status,
|
||||
})
|
||||
|
||||
const headersWithGetSetCookie = result.headers as Headers & { getSetCookie?: () => string[] | undefined }
|
||||
let setCookieHeaders =
|
||||
typeof headersWithGetSetCookie.getSetCookie === "function"
|
||||
? headersWithGetSetCookie.getSetCookie() ?? []
|
||||
: []
|
||||
|
||||
if (setCookieHeaders.length === 0) {
|
||||
const single = result.headers.get("set-cookie")
|
||||
if (single) {
|
||||
setCookieHeaders = [single]
|
||||
}
|
||||
}
|
||||
|
||||
for (const cookie of setCookieHeaders) {
|
||||
response.headers.append("set-cookie", cookie)
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue