fix: 401-401 retry on non-401, move login DOM bindings into page lifecycle, add abort support
This commit is contained in:
@@ -23,28 +23,38 @@ import {
|
||||
Badge,
|
||||
startRegistration,
|
||||
webauthnSupported,
|
||||
isModalProcessing,
|
||||
setModalProcessing,
|
||||
} from '/static/hoover/index.js?v=12';
|
||||
import { isModalProcessing, setModalProcessing } from '/static/hoover/components/modal.js?v=9';
|
||||
|
||||
const state = reactive({ credentials: [], loading: true, refreshing: false, error: null });
|
||||
|
||||
async function loadCredentials() {
|
||||
async function loadCredentials(abortController) {
|
||||
if (abortController?.signal?.aborted) return;
|
||||
if (state.credentials.length) state.refreshing = true;
|
||||
else state.loading = true;
|
||||
state.error = null;
|
||||
|
||||
try {
|
||||
const res = await apiFetch('/api/auth/webauthn/credentials');
|
||||
const res = await apiFetch('/api/auth/webauthn/credentials', {
|
||||
signal: abortController?.signal,
|
||||
});
|
||||
if (abortController?.signal?.aborted) return;
|
||||
if (res.ok) {
|
||||
state.credentials = res.data || [];
|
||||
} else {
|
||||
state.error = res.error || 'Failed to load credentials';
|
||||
}
|
||||
} catch (e) {
|
||||
state.error = e.message || 'Failed to load credentials';
|
||||
if (!abortController?.signal?.aborted) {
|
||||
state.error = e.message || 'Failed to load credentials';
|
||||
}
|
||||
} finally {
|
||||
if (!abortController?.signal?.aborted) {
|
||||
state.loading = false;
|
||||
state.refreshing = false;
|
||||
}
|
||||
}
|
||||
state.loading = false;
|
||||
state.refreshing = false;
|
||||
}
|
||||
|
||||
function addCredentialModal() {
|
||||
@@ -277,7 +287,7 @@ const Page = definePage({
|
||||
},
|
||||
|
||||
async load(s, abortController) {
|
||||
await loadCredentials();
|
||||
await loadCredentials(abortController);
|
||||
},
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user