32 lines
1002 B
JavaScript
32 lines
1002 B
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.ok;
|
|
} catch {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
signOut: async function () {
|
|
try {
|
|
const response = await fetch('/_auth/signout', {
|
|
method: 'POST',
|
|
credentials: 'include'
|
|
});
|
|
return response.ok;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
};
|