feat: enhance Google SSO management by adding save and clear buttons
All checks were successful
Build & Push / Build & Push image (push) Successful in 40s
All checks were successful
Build & Push / Build & Push image (push) Successful in 40s
This commit is contained in:
@@ -409,6 +409,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
document.getElementById('btnConfirmUser') && bind('btnConfirmUser', 'click', addUser);
|
document.getElementById('btnConfirmUser') && bind('btnConfirmUser', 'click', addUser);
|
||||||
document.getElementById('auditCategory') && bind('auditCategory', 'change', loadAuditLog);
|
document.getElementById('auditCategory') && bind('auditCategory', 'change', loadAuditLog);
|
||||||
document.getElementById('auditSearch') && bind('auditSearch', 'input', loadAuditLog);
|
document.getElementById('auditSearch') && bind('auditSearch', 'input', loadAuditLog);
|
||||||
|
document.getElementById('btnSaveSso') && bind('btnSaveSso', 'click', saveSso);
|
||||||
|
document.getElementById('btnClearSso') && bind('btnClearSso', 'click', clearSso);
|
||||||
// Redirect URI is altijd bekend — vul meteen in zodat het niet "Laden..." blijft
|
// Redirect URI is altijd bekend — vul meteen in zodat het niet "Laden..." blijft
|
||||||
const redirectEl = document.getElementById('redirectUriDisplay');
|
const redirectEl = document.getElementById('redirectUriDisplay');
|
||||||
if (redirectEl) redirectEl.textContent = window.location.origin + '/auth/google/callback';
|
if (redirectEl) redirectEl.textContent = window.location.origin + '/auth/google/callback';
|
||||||
@@ -418,7 +420,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
document.getElementById('schoolName').textContent = me.user?.school_name || '';
|
document.getElementById('schoolName').textContent = me.user?.school_name || '';
|
||||||
await loadUsers();
|
await loadUsers();
|
||||||
await loadKlassen();
|
await loadKlassen();
|
||||||
await loadSsoStatus();
|
loadSsoStatus(me.user?.school); // geef school direct mee — geen extra API call nodig
|
||||||
await loadAuditLog();
|
await loadAuditLog();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -667,11 +669,14 @@ async function loadAuditLog(page = 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Google SSO beheer ─────────────────────────────────────────────────────────
|
// ── Google SSO beheer ─────────────────────────────────────────────────────────
|
||||||
async function loadSsoStatus() {
|
async function loadSsoStatus(school) {
|
||||||
const res = await fetch('/admin/schools');
|
// Als geen school meegegeven: haal op via /api/me (school_ict heeft geen toegang tot /admin/schools)
|
||||||
if (!res.ok) return;
|
if (!school) {
|
||||||
const data = await res.json();
|
const res = await fetch('/api/me');
|
||||||
const school = (data.schools || []).find(s => s.id === mySchoolId);
|
if (!res.ok) return;
|
||||||
|
const data = await res.json();
|
||||||
|
school = data.user?.school;
|
||||||
|
}
|
||||||
|
|
||||||
const statusEl = document.getElementById('ssoStatus');
|
const statusEl = document.getElementById('ssoStatus');
|
||||||
if (!statusEl || !school) return;
|
if (!statusEl || !school) return;
|
||||||
@@ -716,7 +721,7 @@ async function saveSso() {
|
|||||||
document.getElementById('ssoClientId').value = '';
|
document.getElementById('ssoClientId').value = '';
|
||||||
document.getElementById('ssoClientSecret').value = '';
|
document.getElementById('ssoClientSecret').value = '';
|
||||||
notify('Google SSO ingesteld ✅', 'success');
|
notify('Google SSO ingesteld ✅', 'success');
|
||||||
await loadSsoStatus();
|
await loadSsoStatus(); // herlaadt via /api/me
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearSso() {
|
async function clearSso() {
|
||||||
|
|||||||
Reference in New Issue
Block a user