feat(FE) : implementasi hak akses

This commit is contained in:
Yusron alamsyah
2026-02-27 13:26:52 +07:00
parent 23f668ae3f
commit a1efe0a73b
20 changed files with 1178 additions and 392 deletions
+27
View File
@@ -0,0 +1,27 @@
// plugins/auth.client.ts
// This plugin initializes authentication state once on app load
// Runs only on client-side before any components mount
export default defineNuxtPlugin({
name: 'auth',
enforce: 'pre', // Run before other plugins
async setup(nuxtApp) {
const { checkAuth, user } = useAuth();
try {
// Initialize auth state once on app load
// This MUST complete before app renders
const userData = await checkAuth();
if (userData) {
console.log('✅ Auth plugin: User authenticated');
} else {
console.log(' Auth plugin: No active session');
}
} catch (err) {
console.error('❌ Auth plugin: Failed to initialize auth:', err);
}
}
});