Various fixes and cleanup, regressions from prior commits.
This commit is contained in:
@@ -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 ''
|
||||
|
||||
Reference in New Issue
Block a user