Upload via GUI (452 Dateien)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
require_once __DIR__ . '/../includes/totp.php';
|
||||
require_once __DIR__ . '/../includes/webauthn.php';
|
||||
$staff = require_staff_login();
|
||||
$pdo = get_db();
|
||||
|
||||
@@ -134,6 +135,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
redirect('/staff/profile.php?tab=account');
|
||||
}
|
||||
|
||||
// ── Von allen Geräten abmelden ─────────────────────────────────
|
||||
if ($action === 'sign_out_everywhere') {
|
||||
$keep = ($_POST['scope'] ?? 'others') !== 'all';
|
||||
$r = staff_sign_out_everywhere($pdo, (int) $staff['id'], (int) $staff['id'], $keep);
|
||||
if ($keep) {
|
||||
flash('success', 'Alle anderen Geräte sind abgemeldet. Beendete App-Anmeldungen: ' . $r['apps'] . '. Diese Sitzung bleibt angemeldet.');
|
||||
redirect('/staff/profile.php?tab=security');
|
||||
}
|
||||
staff_logout();
|
||||
flash('success', 'Sie sind von allen Geräten abgemeldet. Bitte melden Sie sich neu an.');
|
||||
redirect('/staff/login.php');
|
||||
}
|
||||
|
||||
// ── Gemerktes Gerät entfernen (Anmelde-Wächter) ────────────────
|
||||
if ($action === 'forget_device') {
|
||||
$pdo->prepare('DELETE FROM login_devices WHERE id = ? AND staff_id = ?')->execute([(int) ($_POST['device_id'] ?? 0), $staff['id']]);
|
||||
@@ -141,6 +155,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
redirect('/staff/profile.php?tab=security');
|
||||
}
|
||||
|
||||
// ── Passkey entfernen (das Passwort wird bestätigt) ───────────
|
||||
if ($action === 'delete_passkey') {
|
||||
$pass = $_POST['confirm_password'] ?? '';
|
||||
$me = $pdo->prepare('SELECT password_hash FROM staff WHERE id=?');
|
||||
$me->execute([$staff['id']]);
|
||||
$me = $me->fetch();
|
||||
if (!password_verify($pass, $me['password_hash'])) {
|
||||
flash('error', 'Falsches Passwort.');
|
||||
} else {
|
||||
$del = $pdo->prepare('DELETE FROM staff_passkeys WHERE id = ? AND staff_id = ?');
|
||||
$del->execute([(int) ($_POST['passkey_id'] ?? 0), $staff['id']]);
|
||||
if ($del->rowCount() > 0) {
|
||||
audit_log($staff['id'], 'Passkey entfernt');
|
||||
login_guard_record($pdo, 'passkey_removed', (int) $staff['id'], (string) $staff['email'], 'web', 'Passkey vom Mitarbeiter selbst entfernt');
|
||||
flash('success', 'Passkey entfernt.');
|
||||
}
|
||||
}
|
||||
redirect('/staff/profile.php?tab=security');
|
||||
}
|
||||
|
||||
// ── 2FA aktivieren ─────────────────────────────────────────────
|
||||
if ($action === 'enable_2fa') {
|
||||
$code = trim($_POST['totp_code'] ?? '');
|
||||
@@ -452,6 +486,7 @@ document.getElementById('sig-clear').addEventListener('click', function () {
|
||||
<?php elseif ($tab === 'security'): ?>
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/totp.php';
|
||||
require_once __DIR__ . '/../includes/webauthn.php';
|
||||
$me2 = get_db()->prepare('SELECT totp_enabled, totp_secret, email FROM staff WHERE id=?');
|
||||
$me2->execute([$staff['id']]);
|
||||
$me2 = $me2->fetch();
|
||||
@@ -505,6 +540,85 @@ $myEvents->execute([$staff['id']]);
|
||||
$myEvents = $myEvents->fetchAll();
|
||||
$eventLabels = login_guard_event_labels();
|
||||
?>
|
||||
<?php $myPasskeys = webauthn_staff_passkeys($pdo, (int) $staff['id']); $pkRp = webauthn_rp(); ?>
|
||||
<div class="card" style="margin-top:20px">
|
||||
<h3>🔑 Passkeys</h3>
|
||||
<p class="muted" style="font-size:.88rem">Mit einem Passkey melden Sie sich ohne Passwort an: per Fingerabdruck, Gesicht oder Geräte-PIN (Windows Hello, Handy, Sicherheitsschlüssel). Der Passkey ersetzt Passwort und 2FA-Code; Passwort und 2FA bleiben als Rückfall bestehen. Ein Administrator kann Ihre Passkeys bei Verlust entfernen.</p>
|
||||
<p class="muted" style="font-size:.82rem;margin:0 0 8px">Passkeys gelten für die Domain <strong><?= e($pkRp['id']) ?></strong> (die Adresse, unter der Sie DeskHub aufrufen).</p>
|
||||
<?php if (!webauthn_enabled()): ?>
|
||||
<div class="flash info">Passkeys sind in dieser Installation zurzeit ausgeschaltet. Vorhandene Passkeys bleiben gespeichert, gelten aber erst wieder, wenn ein Administrator sie einschaltet.</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!$pkRp['secure']): ?>
|
||||
<div class="flash error">Passkeys brauchen eine HTTPS-Adresse. Die Website-URL in den Einstellungen beginnt noch nicht mit https://.</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($myPasskeys): ?>
|
||||
<table style="width:100%;font-size:.86rem;margin:10px 0">
|
||||
<thead><tr style="text-align:left"><th>Name</th><th>Hinzugefügt</th><th>Zuletzt benutzt</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($myPasskeys as $k): ?>
|
||||
<tr>
|
||||
<td><?= e($k['name']) ?></td>
|
||||
<td><?= e(date('d.m.Y H:i', strtotime((string) $k['created_at']))) ?></td>
|
||||
<td><?= $k['last_used_at'] ? e(date('d.m.Y H:i', strtotime((string) $k['last_used_at']))) : 'noch nie' ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:flex;gap:6px;align-items:center;justify-content:flex-end" onsubmit="return confirm('Diesen Passkey entfernen?')"><?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete_passkey"><input type="hidden" name="passkey_id" value="<?= (int) $k['id'] ?>">
|
||||
<input type="password" name="confirm_password" placeholder="Passwort" required style="max-width:140px;padding:4px 8px">
|
||||
<button class="btn secondary" type="submit" style="padding:3px 8px;font-size:.78rem">Entfernen</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p class="muted" style="font-size:.88rem">Noch kein Passkey eingerichtet.</p>
|
||||
<?php endif; ?>
|
||||
<div id="passkey-add" style="display:none;margin-top:10px"<?= webauthn_enabled() ? '' : ' data-off="1"' ?>>
|
||||
<h4 style="margin:0 0 6px">Neuen Passkey hinzufügen</h4>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:flex-end">
|
||||
<div><label for="pk_name">Name (z. B. „Laptop“)</label><input type="text" id="pk_name" maxlength="80" placeholder="Mein Laptop" autocomplete="off" data-bwignore="true" data-lpignore="true" data-1p-ignore="true" style="max-width:200px"></div>
|
||||
<div><label for="pk_pass">Ihr Passwort</label><input type="password" id="pk_pass" autocomplete="current-password" style="max-width:200px"></div>
|
||||
<button type="button" class="btn" id="pk_add">Passkey einrichten</button>
|
||||
</div>
|
||||
<div id="pk_msg" class="flash error" style="display:none;margin-top:10px"></div>
|
||||
</div>
|
||||
<p id="pk_unsupported" class="muted" style="font-size:.86rem;display:none">Dieser Browser oder diese Verbindung unterstützt keine Passkeys.</p>
|
||||
<script src="/assets/js/passkey.js?v=<?= @filemtime(__DIR__ . '/../assets/js/passkey.js') ?: time() ?>"></script>
|
||||
<script>
|
||||
(function () {
|
||||
var add = document.getElementById('passkey-add');
|
||||
if (add.getAttribute('data-off')) return;
|
||||
if (!window.DeskHubPasskey || !DeskHubPasskey.supported()) { document.getElementById('pk_unsupported').style.display = 'block'; return; }
|
||||
add.style.display = 'block';
|
||||
var msg = document.getElementById('pk_msg'), btn = document.getElementById('pk_add');
|
||||
btn.addEventListener('click', function () {
|
||||
msg.style.display = 'none';
|
||||
var pass = document.getElementById('pk_pass').value;
|
||||
if (!pass) { msg.textContent = 'Bitte geben Sie Ihr Passwort ein.'; msg.style.display = 'block'; return; }
|
||||
btn.disabled = true;
|
||||
DeskHubPasskey.register(<?= json_encode(csrf_token()) ?>, document.getElementById('pk_name').value, pass)
|
||||
.then(function () { location.href = '/staff/profile.php?tab=security&pk=1'; })
|
||||
.catch(function (e) { msg.textContent = e.message; msg.style.display = 'block'; btn.disabled = false; });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<?php $myApps = staff_app_logins($pdo, (int) $staff['id']); ?>
|
||||
<div class="card" style="margin-top:20px">
|
||||
<h3>Von allen Geräten abmelden</h3>
|
||||
<p class="muted" style="font-size:.88rem">Beendet alle Anmeldungen in Browsern und in den Apps (Android, Windows-Programm, Chrome-Erweiterung) und stoppt die Push-Benachrichtigungen auf diesen Geräten. Sinnvoll, wenn ein Gerät verloren ging oder Sie sich irgendwo angemeldet gelassen haben. Ihr Passwort bleibt unverändert.</p>
|
||||
<?php if ($myApps): ?>
|
||||
<div style="font-size:.84rem;margin:8px 0"><strong>Angemeldete Apps:</strong>
|
||||
<?php foreach ($myApps as $app): ?><div class="muted"><?= e((string) ($app['device_name'] ?: 'Unbekanntes Gerät')) ?> · <?= e($app['last_used_at'] ? 'zuletzt ' . date('d.m.Y H:i', strtotime((string) $app['last_used_at'])) : 'noch nie benutzt') ?></div><?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="btn-row" style="display:flex;gap:10px;flex-wrap:wrap">
|
||||
<form method="post" onsubmit="return confirm('Alle anderen Geräte abmelden? Dieses Gerät bleibt angemeldet.')"><?= csrf_field() ?><input type="hidden" name="action" value="sign_out_everywhere"><input type="hidden" name="scope" value="others"><button type="submit" class="btn secondary">Alle anderen Geräte abmelden</button></form>
|
||||
<form method="post" onsubmit="return confirm('Von allen Geräten abmelden, auch von diesem?')"><?= csrf_field() ?><input type="hidden" name="action" value="sign_out_everywhere"><input type="hidden" name="scope" value="all"><button type="submit" class="btn secondary" style="border-color:var(--danger);color:var(--danger)">Von allen Geräten abmelden (auch hier)</button></form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top:20px">
|
||||
<h3>🛡️ Meine Geräte und Anmeldungen</h3>
|
||||
<p class="muted" style="font-size:.88rem">Von diesen Geräten haben Sie sich schon angemeldet. Meldet sich jemand von einem neuen Gerät oder Ort an, bekommen Sie eine Mail. Ein Gerät, das Sie nicht kennen, können Sie hier entfernen; ändern Sie dann auch Ihr Passwort.</p>
|
||||
|
||||
Reference in New Issue
Block a user