Skip to content

Commit 457b6b1

Browse files
authored
fix: fetch hook is called even is user is not set (#209)
* fix: fetch hook is called even is user is not set * up
1 parent c95cb73 commit 457b6b1

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/runtime/server/api/session.get.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { eventHandler } from 'h3'
22
import { getUserSession, sessionHooks } from '../utils/session'
3-
import type { UserSessionRequired } from '#auth-utils'
43

54
export default eventHandler(async (event) => {
65
const session = await getUserSession(event)
76

87
// If session is not empty, call fetch hook
98
if (Object.keys(session).length > 0) {
10-
await sessionHooks.callHookParallel('fetch', session as UserSessionRequired, event)
9+
await sessionHooks.callHookParallel('fetch', session, event)
1110
}
1211

1312
const { secure, ...data } = session

src/runtime/server/utils/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface SessionHooks {
1111
* - Add extra properties to the session
1212
* - Throw an error if the session could not be verified (with a database for example)
1313
*/
14-
fetch: (session: UserSessionRequired, event: H3Event) => void | Promise<void>
14+
fetch: (session: UserSession, event: H3Event) => void | Promise<void>
1515
/**
1616
* Called before clearing the session
1717
*/

0 commit comments

Comments
 (0)