Skip to content

Commit

Permalink
fix: expose plugin name to be used in dependsOn
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed Dec 25, 2024
1 parent 5a7b6c0 commit c2d930b
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,27 @@ function handleIdentityLoadError(error: Error, logger: ConsolaInstance) {
}
}

export default defineNuxtPlugin(async (_nuxtApp) => {
const nuxtApp = _nuxtApp as NuxtApp
const options = useSanctumConfig()
const appConfig = useSanctumAppConfig()
const logger = createSanctumLogger(options.logLevel)
const client = createHttpClient(nuxtApp, logger)

if (options.mode === 'token' && !appConfig.tokenStorage) {
await setupDefaultTokenStorage(nuxtApp, logger)
}
export default defineNuxtPlugin({
name: 'nuxt-auth-sanctum',
async setup(_nuxtApp) {
const nuxtApp = _nuxtApp as NuxtApp
const options = useSanctumConfig()
const appConfig = useSanctumAppConfig()
const logger = createSanctumLogger(options.logLevel)
const client = createHttpClient(nuxtApp, logger)

if (options.mode === 'token' && !appConfig.tokenStorage) {
await setupDefaultTokenStorage(nuxtApp, logger)
}

if (options.client.initialRequest) {
await initialIdentityLoad(client, options, logger)
}
if (options.client.initialRequest) {
await initialIdentityLoad(client, options, logger)
}

return {
provide: {
sanctumClient: client,
},
}
return {
provide: {
sanctumClient: client,
},
}
},
})

0 comments on commit c2d930b

Please sign in to comment.