chartboard/app/Views/profile/index.php
2026-03-30 09:51:33 +05:30

95 lines
4.2 KiB
PHP

<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>
<header class="cb-page-header">
<div>
<h1 class="cb-page-title">Profile</h1>
<p class="cb-page-subtitle mb-0">Your account, password, and API access.</p>
</div>
</header>
<div class="cb-page-body">
<div class="row g-4">
<div class="col-lg-6">
<div class="card border-0 shadow-sm">
<div class="card-body">
<h2 class="h5 mb-3">Profile</h2>
<?php if (session()->getFlashdata('success')): ?>
<div class="alert alert-success"><?= esc(session()->getFlashdata('success')) ?></div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"><?= esc(session()->getFlashdata('error')) ?></div>
<?php endif; ?>
<?php if (session()->getFlashdata('errors')): ?>
<div class="alert alert-danger">
<ul class="mb-0">
<?php foreach (session()->getFlashdata('errors') as $error): ?>
<li><?= esc($error) ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<form method="post" action="<?= base_url('profile/update') ?>" enctype="multipart/form-data">
<?= csrf_field() ?>
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" name="name" class="form-control" value="<?= esc($user['name'] ?? '') ?>" required>
</div>
<div class="mb-3">
<label class="form-label">Email</label>
<input type="email" class="form-control" value="<?= esc($user['email'] ?? '') ?>" disabled>
</div>
<div class="mb-3">
<label class="form-label">Avatar</label>
<input type="file" name="avatar" class="form-control" accept=".jpg,.jpeg,.png,.webp">
</div>
<button class="btn btn-primary" type="submit">Update Profile</button>
</form>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card border-0 shadow-sm mb-4">
<div class="card-body">
<h2 class="h5 mb-3">Change Password</h2>
<form method="post" action="<?= base_url('profile/password') ?>">
<?= csrf_field() ?>
<div class="mb-3">
<label class="form-label">Current Password</label>
<input type="password" name="current_password" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">New Password</label>
<input type="password" name="new_password" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Confirm New Password</label>
<input type="password" name="confirm_password" class="form-control" required>
</div>
<button class="btn btn-dark" type="submit">Change Password</button>
</form>
</div>
</div>
<div class="card border-0 shadow-sm">
<div class="card-body">
<h2 class="h5 mb-3">API Token</h2>
<?php if (! empty($plainApiToken)): ?>
<div class="alert alert-warning">
Copy this token now. It will not be shown again:
<code class="d-block mt-2"><?= esc($plainApiToken) ?></code>
</div>
<?php endif; ?>
<form method="post" action="<?= base_url('profile/generate-api-token') ?>">
<?= csrf_field() ?>
<button class="btn btn-outline-primary" type="submit">Regenerate API Token</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?= $this->endSection() ?>