rinkplanner/hub/views/account.php

85 lines
3.9 KiB
PHP
Raw Normal View History

<?php /** @var array $tokens */ ?>
<?php $user = auth_user(); ?>
<section class="page-head">
<div>
<h1><?= e(t('account.title')) ?></h1>
<p class="muted"><?= e($user['username']) ?> · <?= e($user['role'] === 'admin' ? t('account.role_admin') : t('account.role_user')) ?></p>
</div>
</section>
<?php if ($user['must_change_password'] === 1): ?>
<div class="flash flash-info"><?= e(t('account.must_change')) ?></div>
<?php endif; ?>
<div class="columns">
<section class="panel">
<h2><?= e(t('account.change_password')) ?></h2>
<form method="post" action="<?= e(url('/account/password')) ?>" class="stack">
<?= csrf_field() ?>
<label>
<?= e(t('account.current_password')) ?>
<input type="password" name="current_password" autocomplete="current-password" required>
</label>
<label>
<?= e(t('account.new_password')) ?>
<input type="password" name="password" autocomplete="new-password" required>
<span class="hint"><?= e(t('account.password_hint')) ?></span>
</label>
<label>
<?= e(t('account.repeat_password')) ?>
<input type="password" name="password_repeat" autocomplete="new-password" required>
</label>
<button class="primary" type="submit"><?= e(t('account.save_password')) ?></button>
</form>
</section>
<section class="panel">
<h2><?= e(t('account.tokens')) ?></h2>
<p class="muted"><?= e(t('account.tokens_lede')) ?></p>
<form method="post" action="<?= e(url('/account/tokens')) ?>" class="inline-form">
<?= csrf_field() ?>
<input type="text" name="name" maxlength="64" placeholder="<?= e_attr(t('account.token_placeholder')) ?>" required>
<button type="submit"><?= e(t('account.token_create')) ?></button>
</form>
<?php if ($tokens): ?>
<div class="table-wrap">
<table class="list compact">
<thead>
<tr>
<th><?= e(t('table.name')) ?></th>
<th><?= e(t('table.prefix')) ?></th>
<th><?= e(t('table.created')) ?></th>
<th><?= e(t('table.last_used')) ?></th>
<th><?= e(t('table.status')) ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($tokens as $token): ?>
<tr>
<td><?= e($token['name']) ?></td>
<td><code><?= e($token['prefix']) ?>…</code></td>
<td><?= e(fmt_dt($token['created_at'])) ?></td>
<td><?= e(fmt_dt($token['last_used_at'])) ?></td>
<td><?= e($token['revoked_at'] !== null ? t('account.token_revoked') : t('account.token_active')) ?></td>
<td>
<?php if ($token['revoked_at'] === null): ?>
<form class="inline" method="post" action="<?= e(url('/account/tokens/revoke')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="token_id" value="<?= (int) $token['id'] ?>">
<button class="link-button danger" type="submit"><?= e(t('account.token_revoke')) ?></button>
</form>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php else: ?>
<p class="muted small"><?= e(t('account.no_tokens')) ?></p>
<?php endif; ?>
</section>
</div>