snappymail/plugins/proxy-auth/js/auto-login.js
2024-01-21 14:57:47 +01:00

33 lines
926 B
JavaScript

(rl => {
rl && addEventListener('rl-view-model', e => {
const id = e.detail.viewModelTemplateID;
if (e.detail && ('Login' === id)) {
let
auto_login = window.rl.pluginSettingsGet('proxy-auth', 'auto_login');
;
const
ForwardProxyAuth = () => {
if (auto_login) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/?UserHeaderSet", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
window.location.href = "/?ProxyAuth";
}
};
xhr.send();
}
};
window.ForwardProxyAuth = ForwardProxyAuth;
ForwardProxyAuth();
}
});
})(window.rl);