- 1 :
- 2 :
/**
- 3 :
* Plugin roundcube_auth - Associated JS file
- 4 :
*/
- 5 :
function docReady(fn)
- 6 :
{
- 7 :
// see if DOM is already available
- 8 :
if (document.readyState === "complete"
- 9 :
|| document.readyState === "interactive")
- 10 :
{
- 11 :
// call on next available tick
- 12 :
setTimeout(fn, 1);
- 13 :
} else { document.addEventListener("DOMContentLoaded", fn); }
- 14 :
}
- 15 :
- 16 :
docReady(function()
- 17 :
{
- 18 :
// DOM is loaded and ready for manipulation here
- 19 :
- 20 :
//=====
- 21 :
//
- 22 :
//=====
- 23 :
if(window.rcmail)
- 24 :
{
- 25 :
// NOT USED CURRENTLY
- 26 :
rcmail.addEventListener('plugin.auth_redirect', function(evt)
- 27 :
{
- 28 :
// console.log("PLUGIN_AUTH_REDIRECT");
- 29 :
// console.log(evt);
- 30 :
// console.log(window.location);
- 31 :
// // window.location
- 32 :
// const baseURL = "https://rcube.preprod.m2.e2.rie.gouv.fr/bureau/"
- 33 :
// window.location.replace(`${baseURL}?${evt}`);
- 34 :
});
- 35 :
}
- 36 :
- 37 :
//=====
- 38 :
//
- 39 :
//=====
- 40 :
const forms = document.getElementsByTagName('form');
- 41 :
- 42 :
if(forms.length > 0)
- 43 :
{
- 44 :
for (let form of forms)
- 45 :
{
- 46 :
// Select login form
- 47 :
if(form.action.includes('?_task=login'))
- 48 :
{
- 49 :
form.addEventListener('submit', (e) =>
- 50 :
{
- 51 :
// Select OIDC button
- 52 :
if(e.submitter.id == "rcmlogin_oidc")
- 53 :
{
- 54 :
// Avoid form submission
- 55 :
e.preventDefault();
- 56 :
- 57 :
// Redirect to OIDC route
- 58 :
window.location.replace(`${window.location.origin}?oidc=1`);
- 59 :
}
- 60 :
});
- 61 :
}
- 62 :
}
- 63 :
}
- 64 :
});