From 3127ccbdbe0b232cdb2923d14877c256ebe1d83f Mon Sep 17 00:00:00 2001 From: chloe Date: Thu, 12 Mar 2026 15:30:19 +0000 Subject: [PATCH] Login updated --- Seasoned.Frontend/app/app.vue | 13 +++++++--- Seasoned.Frontend/app/pages/login.vue | 36 ++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Seasoned.Frontend/app/app.vue b/Seasoned.Frontend/app/app.vue index 270c82f..23485ec 100644 --- a/Seasoned.Frontend/app/app.vue +++ b/Seasoned.Frontend/app/app.vue @@ -29,7 +29,7 @@ import '@/assets/css/app-theme.css' +const isLoggedIn = useState('isLoggedIn', () => false) +const tokenCookie = useCookie('seasoned_token') -const token = useCookie('seasoned_token') +onMounted(() => { + if (tokenCookie.value) { + isLoggedIn.value = true + } +}) const logout = () => { - token.value = null + tokenCookie.value = null + isLoggedIn.value = false if (import.meta.client) { localStorage.removeItem('token') diff --git a/Seasoned.Frontend/app/pages/login.vue b/Seasoned.Frontend/app/pages/login.vue index b65f3b5..d14a010 100644 --- a/Seasoned.Frontend/app/pages/login.vue +++ b/Seasoned.Frontend/app/pages/login.vue @@ -114,11 +114,41 @@ const handleAuth = async () => { }) if (isLogin.value) { - navigateTo('/gallery') - + const isLoggedIn = useState('isLoggedIn') + isLoggedIn.value = true + snackbar.value = { + show: true, + message: 'Welcome back!', + color: '#f4ede1', + icon: 'mdi-account-check', + iconColor: '#556b2f', + textColor: '#5d4037' + } + setTimeout(() => { + navigateTo('/') + }, 1200) + } else { + snackbar.value = { + show: true, + message: 'Account created! Try signing in.', + color: '#f4ede1', + icon: 'mdi-feather', + iconColor: '#556b2f', + textColor: '#5d4037' + } + isLogin.value = true + authLoading.value = false } } catch (err) { - alert("Authentication failed. Check your credentials.") + authLoading.value = false + snackbar.value = { + show: true, + message: 'The archives do not recognize these credentials.', + color: '#efe5e3', + icon: 'mdi-alert-rhombus', + iconColor: '#8c4a32', + textColor: '#5d4037' + } } } \ No newline at end of file