From 77c82e7f063acbd000efc885c57a7f397f82ac7c Mon Sep 17 00:00:00 2001 From: Gerben Mulder Date: Wed, 3 Apr 2024 19:08:27 +0200 Subject: [PATCH] fix(types): narrowed session type passed to fetch session hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: narrowed session type passed to `fetch` session hook * fix: type import * chore: up --------- Co-authored-by: Sébastien Chopin --- src/runtime/server/utils/session.ts | 8 ++++---- src/runtime/types/index.ts | 2 +- src/runtime/types/session.ts | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/runtime/server/utils/session.ts b/src/runtime/server/utils/session.ts index f91a198d..d04ef9c4 100644 --- a/src/runtime/server/utils/session.ts +++ b/src/runtime/server/utils/session.ts @@ -3,7 +3,7 @@ import { useSession, createError } from 'h3' import { defu } from 'defu' import { createHooks } from 'hookable' import { useRuntimeConfig } from '#imports' -import type { User, UserSession } from '#auth-utils' +import type { UserSession, UserSessionRequired } from '#auth-utils' export interface SessionHooks { /** @@ -11,7 +11,7 @@ export interface SessionHooks { * - Add extra properties to the session * - Throw an error if the session could not be verified (with a database for example) */ - 'fetch': (session: UserSession, event: H3Event) => void | Promise + 'fetch': (session: UserSessionRequired, event: H3Event) => void | Promise /** * Called before clearing the session */ @@ -59,7 +59,7 @@ export async function clearUserSession (event: H3Event) { return true } -export async function requireUserSession(event: H3Event): Promise { +export async function requireUserSession(event: H3Event): Promise { const userSession = await getUserSession(event) if (!userSession.user) { @@ -69,7 +69,7 @@ export async function requireUserSession(event: H3Event): Promise user: ComputedRef