Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/runtime/app/composables/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ export function useUserSession(): UserSessionComposable {
}
}
const openInPopup = (route: string, size: { width?: number, height?: number } = {}) => {
// Set a local storage item to tell the popup that we pending auth
localStorage.setItem('temp-nuxt-auth-utils-popup', 'true')
try {
// Set a local storage item to tell the popup that we pending auth
localStorage.setItem('temp-nuxt-auth-utils-popup', 'true')
}
catch (error) {
console.error('[nuxt-auth-utils] Could not use localStorage during popup flow initialization.', error)
}

const width = size.width ?? 960
const height = size.height ?? 600
Expand Down
15 changes: 10 additions & 5 deletions src/runtime/app/plugins/session.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ export default defineNuxtPlugin(async (nuxtApp: NuxtApp) => {
})
}

if (localStorage.getItem('temp-nuxt-auth-utils-popup')) {
// There is a local storage item. That's mean we are coming back in the popup
localStorage.removeItem('temp-nuxt-auth-utils-popup')
const error = useError()
if (!error.value) window.close()
try {
if (localStorage.getItem('temp-nuxt-auth-utils-popup')) {
// There is a local storage item. That's mean we are coming back in the popup
localStorage.removeItem('temp-nuxt-auth-utils-popup')
const error = useError()
if (!error.value) window.close()
}
}
catch (error) {
console.error('[nuxt-auth-utils] Could not use localStorage during popup flow last step. Popup won\'t be closed automatically.', error)
}
})