replace password-handling with hint

also add hint to email-field
This commit is contained in:
Jakobus Schürz 2025-01-17 03:04:31 +01:00 committed by Hypolite Petovan
parent 792f50f835
commit c506367273

View file

@ -78,26 +78,32 @@ function saml_install()
function saml_footer(string &$body) function saml_footer(string &$body)
{ {
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement'))); $fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
$samlhint = DI::l10n()->t('managed via SAML authentication');
$body .= <<<EOL $body .= <<<EOL
<script> <script>
var target=$("#settings-nickname-desc"); var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); } if (target.length) { target.append("<p>$fragment</p>"); }
document.getElementById('id_email').setAttribute('readonly', 'readonly'); document.getElementById('id_email').setAttribute('readonly', 'readonly');
if ( document.getElementById('password-settings') != null ) { var saml_hint = document.createElement("span");
document.getElementById('password-settings').remove(); var saml_hint_text = document.createTextNode('$samlhint');
} saml_hint.appendChild(saml_hint_text);
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
// Frio theme
if ( document.getElementById('password-settings-collapse') != null ) { if ( document.getElementById('password-settings-collapse') != null ) {
document.getElementById('password-settings-collapse').remove(); document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));
} }
if ( document.getElementById('id_mpassword_wrapper') != null ) { if ( document.getElementById('id_mpassword_wrapper') != null ) {
document.getElementById('id_mpassword_wrapper').parentNode.appendChild(saml_hint.cloneNode(true));
document.getElementById('id_mpassword_wrapper').remove(); document.getElementById('id_mpassword_wrapper').remove();
document.getElementById('id_email').nextElementSibling.classList.add('help-block');
} }
// Vier theme
if ( document.getElementById('wrapper_mpassword') != null ) { if ( document.getElementById('wrapper_mpassword') != null ) {
document.getElementById('wrapper_mpassword').remove(); document.getElementById('wrapper_mpassword').remove();
document.getElementById('id_email').nextElementSibling.classList.add('field_help');
} }
if ( document.getElementById('wrapper_password') != null ) { if ( document.getElementById('wrapper_password') != null ) {
document.getElementById('wrapper_password').parentNode.parentNode.children[0].remove(); document.getElementById('wrapper_password').parentNode.replaceChildren(saml_hint.cloneNode(true));
document.getElementById('wrapper_password').parentNode.remove();
} }
</script> </script>
EOL; EOL;