Skip to content

Commit

Permalink
Merge branch 'dev' into feat/devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac authored Mar 6, 2023
2 parents f71b571 + a45eab4 commit 6f4525d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/runtime/composables/useStrapiAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useStrapiAuth = () => {
}

const fetchUser = async (): Promise<Ref<StrapiUser>> => {
if (token.value && !user.value) {
if (token.value) {
try {
user.value = await client('/users/me', { params: config.strapi.auth })
} catch (e) {
Expand Down
9 changes: 7 additions & 2 deletions src/runtime/strapi.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { defineNuxtPlugin } from '#app'
import { useStrapiAuth } from './composables/useStrapiAuth'
import { useStrapiUser } from './composables/useStrapiUser'

export default defineNuxtPlugin(async () => {
const { fetchUser } = useStrapiAuth()
const user = useStrapiUser()

await fetchUser()
if (!user.value) {
const { fetchUser } = useStrapiAuth()

await fetchUser()
}
})

0 comments on commit 6f4525d

Please sign in to comment.