140 lines
5.1 KiB
PHP
140 lines
5.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>
|
||
|
||
<label>
|
||
<span>Телефон</span>
|
||
<input type="tel" name="phone" value="<?= View::e((string) $user->phone) ?>" placeholder="+7 900 000-00-00">
|
||
</label>
|
||
|
||
<label>
|
||
<span>Сайт</span>
|
||
<input type="url" name="website" value="<?= View::e((string) $user->website) ?>" placeholder="https://example.com">
|
||
</label>
|
||
|
||
<label>
|
||
<span>Должность</span>
|
||
<input type="text" name="position" value="<?= View::e((string) $user->position) ?>">
|
||
</label>
|
||
|
||
<label>
|
||
<span>Город</span>
|
||
<input type="text" name="location" value="<?= View::e((string) $user->location) ?>">
|
||
</label>
|
||
|
||
<label>
|
||
<span>О себе</span>
|
||
<textarea name="bio" style="min-height: 70px;"><?= View::e((string) $user->bio) ?></textarea>
|
||
</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>
|