diff --git a/lms/hooks.py b/lms/hooks.py index 337db658..256513c3 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -21,7 +21,9 @@ app_license = "AGPL" # include js, css files in header of web template web_include_css = "lms.bundle.css" # web_include_css = "/assets/lms/css/lms.css" -web_include_js = [] +web_include_js = [ + "/assets/lms/js/eduvia_sso_login.js", +] # include custom scss in every website theme (without file extension ".scss") # website_theme_scss = "lms/public/scss/website" diff --git a/lms/public/js/eduvia_sso_login.js b/lms/public/js/eduvia_sso_login.js new file mode 100644 index 00000000..3303e6e7 --- /dev/null +++ b/lms/public/js/eduvia_sso_login.js @@ -0,0 +1,25 @@ +document.addEventListener('DOMContentLoaded', () => { + if (location.pathname !== '/login') return; + + const target = + document.querySelector('.page-card .page-card-actions') || + document.querySelector('form#login_form') || + document.querySelector('.page-card'); + + if (!target || document.getElementById('eduvia-login-btn')) return; + + const btn = document.createElement('a'); + btn.id = 'eduvia-login-btn'; + btn.href = '/eduvia/sso/start?return=' + encodeURIComponent(location.href); + btn.className = 'btn btn-primary btn-block mt-3'; + btn.innerText = 'Se connecter avec Eduvia'; + + if (target.tagName && target.tagName.toLowerCase() === 'form') { + const div = document.createElement('div'); + div.className = 'mt-3'; + div.appendChild(btn); + target.appendChild(div); + } else { + target.appendChild(btn); + } + }); \ No newline at end of file