// Shared global state for current user const currentUser = ref({ prefix: 'นาย', firstName: 'สมชาย', lastName: 'ใจดี', email: 'student@example.com', photoURL: '' // Set to URL if available }) export const useAuth = () => { const token = useCookie('auth_token', { maxAge: 60 * 60 * 24 * 7, // 1 week sameSite: 'lax', secure: process.env.NODE_ENV === 'production' }) const isAuthenticated = computed(() => !!token.value) const login = (mockToken: string = 'demo-token') => { token.value = mockToken } const logout = () => { token.value = null // Reset user photo if needed on logout // currentUser.value.photoURL = '' return navigateTo('/auth/login', { replace: true }) } return { isAuthenticated, token, currentUser, login, logout } }