From 558edf2e9af0b5e765fe476a90b83d70971740c7 Mon Sep 17 00:00:00 2001 From: kevin olson Date: Tue, 28 Jan 2025 23:03:16 -0600 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20simplify=20our=20auth=20ut?= =?UTF-8?q?ils=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module.ts | 8 ++++---- src/runtime/care.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/module.ts b/src/module.ts index 18d607a..5f9b158 100644 --- a/src/module.ts +++ b/src/module.ts @@ -5,8 +5,8 @@ export interface ModuleOptions { apiKey: string apiDomain: string verbose: boolean - userFromAuthUtils: boolean - authUtilsUserFields: string[] + authUtils: boolean + authUtilsFields: string[] } declare module 'nuxt/schema' { @@ -37,13 +37,13 @@ declare module 'nuxt/schema' { * @default false */ - userFromAuthUtils?: boolean + authUtils?: boolean /** * Customize the fields that are plucked from the user supplied from nuxt-auth-utils * * @default ['id', 'email', 'name', 'avatar'] */ - authUtilsUserFields?: string[] + authUtilsFields?: string[] } } } diff --git a/src/runtime/care.ts b/src/runtime/care.ts index d158980..42409ed 100644 --- a/src/runtime/care.ts +++ b/src/runtime/care.ts @@ -30,8 +30,8 @@ interface ErrorMeta { export const careConfigDefaults = { apiDomain: 'https://fume.care', verbose: false, - userFromAuthUtils: false, - authUtilsUserFields: ['id', 'email', 'name', 'avatar'], + authUtils: false, + authUtilsFields: ['id', 'email', 'name', 'avatar'], } const mergeConfig = (config: Config) => { @@ -66,15 +66,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.userFromAuthUtils && !event && typeof useUserSession === 'function') { + if (config.authUtils && !event && typeof useUserSession === 'function') { const { user } = useUserSession() - meta.user = userFromFields(user.value, config.authUtilsUserFields) + meta.user = userFromFields(user.value, config.authUtilsFields) } // if we are incorporating nuxt-auth-utils in server/ - if (config.userFromAuthUtils && event && typeof getUserSession === 'function') { + if (config.authUtils && event && typeof getUserSession === 'function') { const { user } = await getUserSession(event) - meta.user = userFromFields(user, config.authUtilsUserFields) + meta.user = userFromFields(user, config.authUtilsFields) } if (config.verbose) log.info('[fume.care] stored meta being sent:', JSON.stringify(meta)) return meta