Await dynamic APIs in auth server helpers
This commit is contained in:
parent
e491becbc4
commit
9cdd8763b4
2 changed files with 8 additions and 8 deletions
|
|
@ -57,9 +57,9 @@
|
||||||
|
|
||||||
## Rotina antes de abrir PR
|
## Rotina antes de abrir PR
|
||||||
- `pnpm lint`
|
- `pnpm lint`
|
||||||
|
- `pnpm build --turbopack`
|
||||||
- `pnpm exec vitest run`
|
- `pnpm exec vitest run`
|
||||||
- Revisar toasts/labels em PT-BR e ausência de segredos no diff.
|
- Revisar toasts/labels em PT-BR e ausência de segredos no diff.
|
||||||
- Adicionar coautor `factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>` quando aplicável.
|
|
||||||
|
|
||||||
## Convenções
|
## Convenções
|
||||||
- Convex deve retornar apenas tipos primitivos; converta datas via mappers em `src/lib/mappers`.
|
- Convex deve retornar apenas tipos primitivos; converta datas via mappers em `src/lib/mappers`.
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@ import { isAdmin, isStaff } from "@/lib/authz"
|
||||||
|
|
||||||
type ServerSession = Awaited<ReturnType<typeof getCookieCache>>
|
type ServerSession = Awaited<ReturnType<typeof getCookieCache>>
|
||||||
|
|
||||||
function serializeCookies() {
|
async function serializeCookies() {
|
||||||
const store = cookies()
|
const store = await cookies()
|
||||||
return store.getAll().map((cookie) => `${cookie.name}=${cookie.value}`).join("; ")
|
return store.getAll().map((cookie) => `${cookie.name}=${cookie.value}`).join("; ")
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRequest() {
|
async function buildRequest() {
|
||||||
const cookieHeader = serializeCookies()
|
const cookieHeader = await serializeCookies()
|
||||||
const headerList = headers()
|
const headerList = await headers()
|
||||||
const userAgent = headerList.get("user-agent") ?? ""
|
const userAgent = headerList.get("user-agent") ?? ""
|
||||||
const ip =
|
const ip =
|
||||||
headerList.get("x-forwarded-for") ||
|
headerList.get("x-forwarded-for") ||
|
||||||
|
|
@ -35,7 +35,7 @@ function buildRequest() {
|
||||||
|
|
||||||
export async function getServerSession(): Promise<ServerSession | null> {
|
export async function getServerSession(): Promise<ServerSession | null> {
|
||||||
try {
|
try {
|
||||||
const request = buildRequest()
|
const request = await buildRequest()
|
||||||
const session = await getCookieCache(request)
|
const session = await getCookieCache(request)
|
||||||
return session ?? null
|
return session ?? null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue