Skip to content

Commit d6e3fa2

Browse files
authored
feat(frontend): improve auth UX and prevent form persistence (#48)
1 parent 047560c commit d6e3fa2

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

frontend/src/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { RouterView } from 'vue-router'
2+
import { RouterView, useRoute } from 'vue-router'
33
import MainLayout from '@/shared/components/layout/MainLayout.vue'
44
import { Toaster } from '@/shared/ui/sonner'
55
import { useAuthStore } from '@/modules/auth/stores/useAuthStore'
@@ -9,6 +9,7 @@ import { useEnhancedToast } from './shared/composables/useEnhancedToast'
99
import { queryClient } from './shared/plugins/vue-query'
1010
1111
const auth = useAuthStore()
12+
const route = useRoute()
1213
const { showError } = useEnhancedToast()
1314
1415
const globalErrorHandler = (error: unknown) => {
@@ -43,7 +44,7 @@ window.addEventListener('message', async event => {
4344
<MainLayout>
4445
<RouterView v-slot="{ Component }">
4546
<Transition name="page" mode="out-in" appear>
46-
<component :is="Component" />
47+
<component :is="Component" :key="route.fullPath" />
4748
</Transition>
4849
</RouterView>
4950
</MainLayout>

frontend/src/modules/events/components/EventLinksFormField.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ function removeLink(index: number) {
5959
<Input
6060
type="url"
6161
placeholder="https://..."
62+
autocomplete="off"
6263
:model-value="link.url"
6364
@update:model-value="val => update(i, { url: String(val) })"
6465
/>
6566

6667
<!-- Label -->
6768
<Input
6869
placeholder="Label"
70+
autocomplete="off"
6971
:model-value="link.label"
7072
@update:model-value="val => update(i, { label: String(val) })"
7173
/>

frontend/src/modules/tags/components/TagsDataGrid.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const handleSearchKeydown = (event: KeyboardEvent) => {
5555
<div class="flex-1">
5656
<Input
5757
v-model="localSearchValue"
58+
autocomplete="off"
5859
placeholder="Search tags..."
5960
class="max-w-xs"
6061
@keydown="handleSearchKeydown"

frontend/src/router/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useAuthStore } from '@/modules/auth/stores/useAuthStore'
33
import { routes } from './routes'
44

55
const publicPages = ['/login', '/signup', '/landing', '/oauth/callback']
6+
const authPages = ['/login', '/signup']
67

78
const router = createRouter({
89
history: createWebHistory(),
@@ -19,8 +20,11 @@ const router = createRouter({
1920
router.beforeEach((to, _from, next) => {
2021
const auth = useAuthStore()
2122
const isPublic = publicPages.includes(to.path)
23+
const isAuthPage = authPages.includes(to.path)
2224

23-
if (!isPublic && !auth.token) {
25+
if (auth.token && isAuthPage) {
26+
next({ path: '/events' })
27+
} else if (!isPublic && !auth.token) {
2428
next({ path: '/login', query: { redirect: to.fullPath } })
2529
} else {
2630
next()

frontend/src/shared/components/data/DataTableInputFilter.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,10 @@ export default {
5959
</script>
6060

6161
<template>
62-
<Input v-model="inputValue" :placeholder="placeholder" @keydown="handleKeydown" />
62+
<Input
63+
v-model="inputValue"
64+
:placeholder="placeholder"
65+
@keydown="handleKeydown"
66+
autocomplete="off"
67+
/>
6368
</template>

0 commit comments

Comments
 (0)