Files
Heimdall/src/Heimdall.Web/wwwroot/js/auth.js
T
arnaud.dartois 49b8bcc895
Heimdall Gitea / Detect CI scope (pull_request) Successful in 8s
Heimdall Gitea / Build and tests (pull_request) Failing after 15m39s
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / CI policy (pull_request) Failing after 5s
fix(auth): safely report cookie sign-in failures
2026-11-08 18:10:25 +01:00

46 lines
1.4 KiB
JavaScript

// ── Cookie auth bridge ───────────────────────────────────────────
// Called from Blazor via IJSRuntime after login/logout to sync the
// middleware-level auth cookie with the Blazor auth state.
window.heimdallAuth = {
signIn: async function (data) {
try {
const response = await fetch('/_auth/signin', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
credentials: 'include'
});
return response.status;
} catch {
return 0;
}
},
signOut: async function () {
try {
const response = await fetch('/_auth/signout', {
method: 'POST',
credentials: 'include'
});
return response.ok;
} catch {
return false;
}
}
};
// -- File download helper --
function downloadFile(filename, mimeType, base64Data) {
var bytes = Uint8Array.from(atob(base64Data), function(c) { return c.charCodeAt(0); });
var blob = new Blob([bytes], { type: mimeType });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}