Various fixes and cleanup, regressions from prior commits.

This commit is contained in:
2025-12-04 03:40:59 +00:00
parent 6124fa6c01
commit 9976e05696
10 changed files with 87 additions and 67 deletions
+9 -13
View File
@@ -145,7 +145,7 @@ async function registerPasskey() {
}
try {
await setSessionCookie(result.session_token)
await setSessionCookie(result)
} catch (error) {
loading.value = false
const message = error?.message || 'Failed to establish session'
@@ -153,23 +153,23 @@ async function registerPasskey() {
return
}
showMessage('Passkey registered successfully!', 'success', 2000)
setTimeout(() => {
loading.value = false
redirectHome()
}, 800)
showMessage('Passkey registered successfully!', 'success', 800)
setTimeout(() => { loading.value = false; goHome() }, 800)
}
async function setSessionCookie(sessionToken) {
async function setSessionCookie(result) {
if (!result?.session_token) {
throw new Error('Registration response missing session_token')
}
return await apiJson('/auth/api/set-session', {
method: 'POST',
headers: {
Authorization: `Bearer ${sessionToken}`
Authorization: `Bearer ${result.session_token}`
}
})
}
function redirectHome() {
function goHome() {
const target = uiBasePath.value || '/auth/'
if (window.location.pathname !== target) {
history.replaceState(null, '', target)
@@ -177,10 +177,6 @@ function redirectHome() {
window.location.reload()
}
function goHome() {
redirectHome()
}
function extractTokenFromPath() {
const segments = window.location.pathname.split('/').filter(Boolean)
if (!segments.length) return ''