Fix the back buttons (navigate back if you can but close if it was a new window).

This commit is contained in:
Leo Vasanko
2025-12-02 18:13:23 +00:00
parent 6f9f4aefc1
commit 7ace4dcb4b
5 changed files with 12 additions and 16 deletions
+3
View File
@@ -3,6 +3,7 @@
<div class="message-content">
<h2>🔒 Access Denied</h2>
<div class="button-row">
<button class="btn-secondary" @click="goBack">Back</button>
<button class="btn-primary" @click="$emit('reload')">Reload Page</button>
</div>
</div>
@@ -10,6 +11,8 @@
</template>
<script setup>
import { goBack } from '@/utils/helpers'
defineEmits(['reload'])
</script>
+2 -1
View File
@@ -64,7 +64,7 @@
<button
type="button"
class="btn-secondary"
@click="history.back()"
@click="goBack"
>
Back
</button>
@@ -100,6 +100,7 @@ import RegistrationLinkModal from '@/components/RegistrationLinkModal.vue'
import { useAuthStore } from '@/stores/auth'
import { adminUiPath, makeUiHref } from '@/utils/settings'
import passkey from '@/utils/passkey'
import { goBack } from '@/utils/helpers'
const authStore = useAuthStore()
const updateInterval = ref(null)
+2 -1
View File
@@ -31,7 +31,7 @@
<button
type="button"
class="btn-secondary"
@click="history.back()"
@click="goBack"
>
Back
</button>
@@ -65,6 +65,7 @@ import { computed, onMounted, ref } from 'vue'
import StatusMessage from '@/components/StatusMessage.vue'
import UserBasicInfo from '@/components/UserBasicInfo.vue'
import { useAuthStore } from '@/stores/auth'
import { goBack } from '@/utils/helpers'
const authStore = useAuthStore()
const initializing = ref(true)
+3 -14
View File
@@ -3,7 +3,7 @@
:mode="authMode"
@authenticated="handleAuthenticated"
@logout="handleLogout"
@back="backNav"
@back="goBack"
@home="returnHome"
/>
</template>
@@ -12,6 +12,7 @@
import { computed, onMounted } from 'vue'
import RestrictedAuth from '@/components/RestrictedAuth.vue'
import { uiBasePath } from '@/utils/settings'
import { goBack } from '@/utils/helpers'
const basePath = computed(() => uiBasePath())
@@ -35,22 +36,10 @@ function returnHome() {
window.location.href = target
}
function backNav() {
try {
if (history.length > 1) {
history.back()
return
}
} catch (_) { /* ignore */ }
returnHome()
}
onMounted(() => {
// Handle Escape key to trigger back navigation
window.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
backNav()
}
if (event.key === 'Escape') goBack()
})
})
</script>
+2
View File
@@ -24,3 +24,5 @@ export function getCookie(name) {
const parts = value.split(`; ${name}=`)
if (parts.length === 2) return parts.pop().split(';').shift()
}
export const goBack = () => history.back() || window.close()