first commit
This commit is contained in:
11
app/plugins/auth-error.ts
Normal file
11
app/plugins/auth-error.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const { data, signOut } = useAuth();
|
||||
|
||||
// Watch for session changes
|
||||
watch(data, async (session) => {
|
||||
if (session?.error === 'RefreshAccessTokenError') {
|
||||
console.warn('Refresh token expired or invalid. Signing out...');
|
||||
await signOut({ callbackUrl: '/auth/login' });
|
||||
}
|
||||
}, { immediate: true });
|
||||
});
|
||||
Reference in New Issue
Block a user