39 lines
2.9 KiB
PHP
39 lines
2.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
// „Mein authentik-Konto“: jeder Mitarbeiter verknüpft sein DeskHub-Konto selbst mit seinem authentik-Konto.
|
|
$staffId = (int) ($staff['id'] ?? 0);
|
|
$message = '';
|
|
$messageType = 'success';
|
|
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') {
|
|
verify_csrf();
|
|
if (($_POST['action'] ?? '') === 'unlink' && authentik_link_of($staffId) !== null) {
|
|
authentik_link_remove($staffId);
|
|
audit_log($staffId, 'authentik: Verknüpfung gelöst');
|
|
$message = 'Die Verknüpfung ist gelöst. Mit authentik melden Sie sich erst wieder an, wenn Sie es neu verknüpfen (oder, falls erlaubt, über die E-Mail-Adresse).';
|
|
}
|
|
}
|
|
$ready = authentik_ready();
|
|
$link = authentik_link_of($staffId);
|
|
$onlyLinked = plugin_setting(AUTHENTIK, 'only_linked', '0') === '1';
|
|
?>
|
|
<h1>Mein authentik-Konto</h1>
|
|
<?php if ($message !== ''): ?><div class="flash <?= $messageType === 'error' ? 'error' : 'success' ?>" role="status"><?= e($message) ?></div><?php endif; ?>
|
|
|
|
<section class="card" style="max-width:760px">
|
|
<?php if (!$ready): ?>
|
|
<p>Die Anmeldung mit authentik ist nicht eingerichtet. Ein Administrator kann sie unter „authentik“ einschalten.</p>
|
|
<?php elseif ($link): ?>
|
|
<p><strong style="color:#157a45">✓ Verknüpft.</strong> Ihr DeskHub-Konto gehört zum authentik-Konto <strong><?= e((string) ($link['email'] ?? '')) ?></strong> (seit <?= e(format_dt((string) ($link['at'] ?? ''))) ?>).</p>
|
|
<p class="muted" style="font-size:.9rem">Mit „<?= e(authentik_config()['label']) ?>“ auf der Anmeldeseite kommen Sie damit direkt in dieses Konto, auch wenn sich die E-Mail-Adresse in authentik oder DeskHub später ändert. Ein anderes authentik-Konto kann dieses DeskHub-Konto nicht öffnen.</p>
|
|
<div style="display:flex;gap:10px;flex-wrap:wrap">
|
|
<a class="btn secondary" href="<?= e(plugin_login_url(AUTHENTIK, 'link')) ?>">Mit einem anderen authentik-Konto neu verknüpfen</a>
|
|
<form method="post" data-confirm="Verknüpfung wirklich lösen?" onsubmit="return confirm(this.dataset.confirm)"><?= csrf_field() ?><input type="hidden" name="action" value="unlink"><button class="btn secondary" type="submit">Verknüpfung lösen</button></form>
|
|
</div>
|
|
<?php else: ?>
|
|
<p><strong style="color:#b45309">Noch nicht verknüpft.</strong> Verknüpfen Sie Ihr DeskHub-Konto einmal mit Ihrem authentik-Konto. Sie melden sich dazu kurz bei authentik an und kommen hierher zurück.</p>
|
|
<p class="muted" style="font-size:.9rem">Danach führt „<?= e(authentik_config()['label']) ?>“ auf der Anmeldeseite genau in dieses Konto. <?= $onlyLinked ? 'Ohne Verknüpfung ist die Anmeldung mit authentik hier nicht möglich.' : 'Auch ohne Verknüpfung klappt die Anmeldung, wenn die E-Mail-Adresse in authentik und DeskHub gleich ist; dabei wird sie dann automatisch verknüpft.' ?></p>
|
|
<a class="btn" href="<?= e(plugin_login_url(AUTHENTIK, 'link')) ?>">Mit authentik verknüpfen</a>
|
|
<?php endif; ?>
|
|
</section>
|