fix: persist default secrets across restarts, auto-relogin on portal expiry, and remove legacy json migration
This commit is contained in:
parent
5d576137ae
commit
43f3891e9e
10 changed files with 835 additions and 625 deletions
|
|
@ -117,6 +117,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
if (res.status === 401) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
|
|
@ -169,6 +173,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
|
||||
try {
|
||||
const res = await fetch(`/api/exams/${encodeURIComponent(examId)}/weaknesses`);
|
||||
if (res.status === 401) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
weaknessLoading.classList.add('hidden');
|
||||
|
||||
|
|
@ -298,11 +306,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
modalLessonPills.innerHTML = '';
|
||||
|
||||
try {
|
||||
// Fetch both Wrong (Y) and Empty (B) questions
|
||||
const [wrongRes, emptyRes] = await Promise.all([
|
||||
fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=Y`).then(r => r.json()),
|
||||
fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=B`).then(r => r.json())
|
||||
]);
|
||||
// Fetch Wrong (Y) and Empty (B) questions sequentially to avoid overloading school report server
|
||||
const wrongResp = await fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=Y`);
|
||||
if (wrongResp.status === 401) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
const wrongRes = await wrongResp.json();
|
||||
|
||||
const emptyResp = await fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=B`);
|
||||
if (emptyResp.status === 401) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
const emptyRes = await emptyResp.json();
|
||||
|
||||
mistakeLoading.classList.add('hidden');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue