Skip to content

Commit

Permalink
🚧 try pulling the functions in
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Jan 30, 2025
1 parent 7d47d00 commit 6951043
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/runtime/care.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ const mergeConfig = (config: Config) => {
...config,
}
}

declare const useUserSession: () => { user: ComputedRef<Record<string, unknown>> }
declare const getUserSession: (event: H3Event) => Promise<{ user: Record<string, unknown> }>

export enum CareHookType {
vueError = 'vue:error',
appError = 'app:error',
Expand All @@ -66,13 +62,15 @@ const getMeta = async (config: Config, event?: H3Event) => {
const meta: ErrorMeta = { user: undefined, meta: undefined }

// if we are incorporating nuxt-auth-utils in app/
if (config.authUtils && !event && typeof useUserSession === 'function') {
if (config.authUtils && !event) {
// @ts-expect-error auto-imported
const { user } = useUserSession()
meta.user = userFromFields(user.value, config.authUtilsFields)
}

// if we are incorporating nuxt-auth-utils in server/
if (config.authUtils && event && typeof getUserSession === 'function') {
if (config.authUtils && event) {
// @ts-expect-error auto-imported
const { user } = await getUserSession(event)
meta.user = userFromFields(user, config.authUtilsFields)
}
Expand Down

0 comments on commit 6951043

Please sign in to comment.