115 lines
4.1 KiB
PHP
115 lines
4.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Свой профиль: данные, пароль и устройства.
|
|
*
|
|
* @var \Rsgrinko\Proton\Models\User $user
|
|
* @var array<int, array{id: string, kind: string, ip: string, agent: string, created: string, last: string, current: bool}> $devices
|
|
*/
|
|
|
|
use Rsgrinko\Proton\Auth\Password;
|
|
use Rsgrinko\Proton\View\View;
|
|
?>
|
|
<h1>Профиль</h1>
|
|
|
|
<div class="grid cols-2">
|
|
<div class="card">
|
|
<h2>Данные</h2>
|
|
|
|
<form method="post" action="<?= View::e(View::route('profile')) ?>">
|
|
<?= View::csrf() ?>
|
|
|
|
<label>
|
|
<span>Логин</span>
|
|
<input type="text" value="<?= View::e((string) $user->login) ?>" disabled>
|
|
</label>
|
|
|
|
<label>
|
|
<span>Имя</span>
|
|
<input type="text" name="name" value="<?= View::e((string) $user->name) ?>">
|
|
</label>
|
|
|
|
<label>
|
|
<span>Почта</span>
|
|
<input type="email" name="email" value="<?= View::e((string) $user->email) ?>">
|
|
</label>
|
|
|
|
<button type="submit" class="primary">Сохранить</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>Пароль</h2>
|
|
|
|
<form method="post" action="<?= View::e(View::route('profile.password')) ?>">
|
|
<?= View::csrf() ?>
|
|
|
|
<label>
|
|
<span>Текущий пароль</span>
|
|
<input type="password" name="current" required>
|
|
</label>
|
|
|
|
<label>
|
|
<span>Новый пароль (от <?= Password::minLength() ?> символов)</span>
|
|
<input type="password" name="password" required>
|
|
</label>
|
|
|
|
<label>
|
|
<span>Новый пароль ещё раз</span>
|
|
<input type="password" name="password_confirmation" required>
|
|
</label>
|
|
|
|
<p class="muted small">Смена пароля завершит сеансы на остальных устройствах.</p>
|
|
|
|
<button type="submit" class="primary">Сменить пароль</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="row">
|
|
<h2 style="margin: 0;">Устройства</h2>
|
|
<span class="spacer"></span>
|
|
|
|
<form method="post" action="<?= View::e(View::route('profile.devices.others')) ?>">
|
|
<?= View::csrf() ?>
|
|
<button type="submit">Выйти на остальных устройствах</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="table-wrap" style="margin-top: 12px;">
|
|
<table class="list">
|
|
<tr class="head">
|
|
<th>Устройство</th>
|
|
<th class="hide-sm">Адрес</th>
|
|
<th class="hide-sm">Начало</th>
|
|
<th>Последний раз</th>
|
|
<th></th>
|
|
</tr>
|
|
|
|
<?php foreach ($devices as $device) { ?>
|
|
<tr>
|
|
<td>
|
|
<?= View::e(View::device($device['agent'])) ?>
|
|
<div class="muted small"><?= View::e($device['kind']) ?><?= $device['current'] ? ' — это устройство' : '' ?></div>
|
|
</td>
|
|
<td class="hide-sm mono"><?= View::e($device['ip']) ?></td>
|
|
<td class="hide-sm muted small"><?= View::e(View::date($device['created'])) ?></td>
|
|
<td class="muted small"><?= View::e(View::ago($device['last'])) ?></td>
|
|
<td class="right">
|
|
<?php if (!$device['current']) { ?>
|
|
<form method="post" action="<?= View::e(View::route('profile.devices.revoke')) ?>">
|
|
<?= View::csrf() ?>
|
|
<input type="hidden" name="device" value="<?= View::e($device['id']) ?>">
|
|
<button type="submit" class="danger">Завершить</button>
|
|
</form>
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</table>
|
|
</div>
|
|
</div>
|