diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-26 14:04:11 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-26 14:04:11 +0200 |
| commit | bfa238c056f31f36c00faad1c5995cbb8af3bd26 (patch) | |
| tree | e35d6b33fff3e79ae905d7dad699134553a1292d /views/profile | |
| parent | c36f74386bcbb19c13915fe3796cb757aa7d1845 (diff) | |
| download | nowayforward_human-bfa238c056f31f36c00faad1c5995cbb8af3bd26.tar nowayforward_human-bfa238c056f31f36c00faad1c5995cbb8af3bd26.tar.gz nowayforward_human-bfa238c056f31f36c00faad1c5995cbb8af3bd26.zip | |
feat!: Rework all views to be used with the router
Diffstat (limited to 'views/profile')
| -rw-r--r-- | views/profile/authenticate.php | 10 | ||||
| -rw-r--r-- | views/profile/index.php | 12 | ||||
| -rw-r--r-- | views/profile/meta.php | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/views/profile/authenticate.php b/views/profile/authenticate.php index 540d4a3..afe1ca7 100644 --- a/views/profile/authenticate.php +++ b/views/profile/authenticate.php @@ -8,17 +8,15 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') { exit; } -include '../meta.php'; +try { + $headers = apache_request_headers(); + $user = Database\Cookie::fromDB($headers["Authorization"]); -$user = null; -runController('user'); - -if ($user !== null) { http_response_code(200); header('Content-Type: text/plain'); echo $user->Username; } -else { +catch(Exception $e) { http_response_code(401); header('Content-Type: text/plain'); echo 'Bad token!'; diff --git a/views/profile/index.php b/views/profile/index.php index 80b0c4a..2334c1b 100644 --- a/views/profile/index.php +++ b/views/profile/index.php @@ -1,9 +1,9 @@ <?php - $title = $_GET["user"] . ' - Profile'; - include '../meta.php'; - $user = null; - runController('user'); + try { + $user = Database\User::fromDB($username); + } + catch(Exception $e) {} ?> <?php if ($user !== null): ?> @@ -12,7 +12,5 @@ <?= $user->Role ?> </section> <?php else: ?> - <h2>User "<?= $_GET["user"] ?>" doesn't exist!</h2> + <h2>User "<?= $username ?>" doesn't exist!</h2> <?php endif; ?> - -<?php end_page(); ?> diff --git a/views/profile/meta.php b/views/profile/meta.php new file mode 100644 index 0000000..52764ef --- /dev/null +++ b/views/profile/meta.php @@ -0,0 +1,4 @@ +<?php + +$username = explode('/', $uri, 4)[2]; +$title = "$username's profile"; |
