25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
(() => {
|
|
'use strict';
|
|
const choice=document.getElementById('auth-remember');
|
|
if(!choice)return;
|
|
const sync=()=>{
|
|
for(const form of document.querySelectorAll('.auth-form')){
|
|
if(form===choice.form)continue;
|
|
const path=new URL(form.action,location.href).pathname;
|
|
if(!['/_/auth/ldap','/_/auth/magic-link'].includes(path))continue;
|
|
let input=form.querySelector('input[name=remember]');
|
|
if(!input){input=document.createElement('input');input.type='hidden';input.name='remember';form.append(input);}
|
|
input.value=choice.checked?'1':'0';
|
|
}
|
|
for(const link of document.querySelectorAll('a.auth-provider-button')){
|
|
const url=new URL(link.href,location.href);
|
|
if(url.origin!==location.origin||url.pathname!=='/_/auth/oidc')continue;
|
|
if(choice.checked)url.searchParams.set('remember','1');else url.searchParams.delete('remember');
|
|
link.href=url.pathname+url.search;
|
|
}
|
|
};
|
|
choice.addEventListener('change',sync);
|
|
window.addEventListener('pageshow',sync);
|
|
sync();
|
|
})();
|