diff options
| author | ilotterytea <iltsu@alright.party> | 2025-08-16 18:32:00 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-08-16 18:32:00 +0500 |
| commit | 25b5223e4b60afa56342db96091797954655df7c (patch) | |
| tree | a294a4da0e1dda4282f86685c8993715a1c4d4fc | |
| parent | b65f988200231ee264337d229f4445038e027d1e (diff) | |
feat: display user status in the header
| -rw-r--r-- | lib/partials.php | 15 | ||||
| -rw-r--r-- | login.php | 1 | ||||
| -rwxr-xr-x | static/img/icons/logout.png | bin | 0 -> 688 bytes | |||
| -rwxr-xr-x | static/img/icons/settings.png | bin | 0 -> 512 bytes |
4 files changed, 14 insertions, 2 deletions
diff --git a/lib/partials.php b/lib/partials.php index e11e194..89ce1cf 100644 --- a/lib/partials.php +++ b/lib/partials.php @@ -1,11 +1,24 @@ <?php function html_navbar() { + session_start(); + $user = $_SESSION['user'] ?? null; echo '' ?> <header> <a href="/"> - <img src="/static/brand/big.webp" alt="ilt.su"> + <img src="/static/img/brand/big.webp" alt="ilt.su"> </a> + <?php if (isset($user)): ?> + <div class="row gap-8 align-center"> + <p>Signed in as <b><?= $user['username'] ?></b></p> + <a href="/account/edit.php"><img src="/static/img/icons/settings.png" alt="Settings" + title="Account settings..."></a> + <a href="/account/logout.php"><img src="/static/img/icons/logout.png" alt="Logout" + title="Logout from the account"></a> + </div> + <?php else: ?> + <a href="/login.php">Log in</a> + <?php endif; ?> </header> <?php ; }
\ No newline at end of file @@ -25,7 +25,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { exit(json_response(401, 'Incorrect username or password.', null)); } - session_start(); $_SESSION['user'] = $user; exit(json_response(200, null, $user)); diff --git a/static/img/icons/logout.png b/static/img/icons/logout.png Binary files differnew file mode 100755 index 0000000..2541d2b --- /dev/null +++ b/static/img/icons/logout.png diff --git a/static/img/icons/settings.png b/static/img/icons/settings.png Binary files differnew file mode 100755 index 0000000..67de2c6 --- /dev/null +++ b/static/img/icons/settings.png |
