Admin-Passwortfeld gegen Autofill absichern
This commit is contained in:
parent
04f1df5abc
commit
4d04e1f8a2
2 changed files with 35 additions and 3 deletions
|
|
@ -754,11 +754,20 @@ if ($page === 'reminder') {
|
|||
|
||||
try {
|
||||
if ($action === 'update' && $userId) {
|
||||
// Passwort nur ändern, wenn die Änderung ausdrücklich per
|
||||
// Checkbox aktiviert wurde. Sonst kann ein vom Browser
|
||||
// automatisch ausgefülltes Passwortfeld das Passwort
|
||||
// unbeabsichtigt überschreiben.
|
||||
$changePassword = ($_POST['change_password'] ?? '') === '1';
|
||||
if ($changePassword && trim((string)($_POST['password'] ?? '')) === '') {
|
||||
throw new \Exception('Bitte ein neues Passwort eingeben oder die Passwortänderung abwählen.');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'firstname' => $_POST['firstname'],
|
||||
'lastname' => $_POST['lastname'],
|
||||
'email' => $_POST['email'],
|
||||
'password' => $_POST['password'],
|
||||
'password' => $changePassword ? ($_POST['password'] ?? '') : '',
|
||||
'iban' => Iban::normalize(trim($_POST['iban'] ?? '')),
|
||||
'paypal' => trim($_POST['paypal'] ?? ''),
|
||||
'mobile' => trim($_POST['mobile'] ?? ''),
|
||||
|
|
|
|||
|
|
@ -44,8 +44,13 @@ require __DIR__ . '/../partials/header.php';
|
|||
<input type="text" id="paypal" name="paypal" maxlength="255" placeholder="E-Mail oder PayPal.Me-Link" value="<?php echo htmlspecialchars((string)$editUser['paypal']); ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Passwort:</label>
|
||||
<input type="password" id="password" name="password" placeholder="Leer lassen, um nicht zu ändern">
|
||||
<label for="change_password">Passwort ändern:</label>
|
||||
<input type="checkbox" id="change_password" name="change_password" value="1">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Neues Passwort:</label>
|
||||
<input type="password" id="password" name="password" autocomplete="new-password"
|
||||
placeholder="Nur ausfüllen, wenn das Passwort geändert werden soll" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="admin">Admin:</label>
|
||||
|
|
@ -136,4 +141,22 @@ require __DIR__ . '/../partials/header.php';
|
|||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var checkbox = document.getElementById('change_password');
|
||||
var password = document.getElementById('password');
|
||||
if (!checkbox || !password) {
|
||||
return;
|
||||
}
|
||||
function syncPasswordField() {
|
||||
password.disabled = !checkbox.checked;
|
||||
if (!checkbox.checked) {
|
||||
password.value = '';
|
||||
}
|
||||
}
|
||||
checkbox.addEventListener('change', syncPasswordField);
|
||||
syncPasswordField();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php require __DIR__ . '/../partials/footer.php'; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue