diff options
| author | Syndamia <kamen@syndamia.com> | 2025-01-26 11:08:46 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2025-01-26 11:09:27 +0200 |
| commit | 76de68d2f3600a7000a054be3f595029b1931e20 (patch) | |
| tree | 35a48cde04501c4992d48f6ed32bb31ea9b597b6 /views/profile/authenticate.php | |
| parent | 723cf2e6cbbea35e8f365d2287d01acb96f02643 (diff) | |
| download | nowayforward_human-76de68d2f3600a7000a054be3f595029b1931e20.tar nowayforward_human-76de68d2f3600a7000a054be3f595029b1931e20.tar.gz nowayforward_human-76de68d2f3600a7000a054be3f595029b1931e20.zip | |
feat: Authentication logic on every page
Diffstat (limited to 'views/profile/authenticate.php')
| -rw-r--r-- | views/profile/authenticate.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/views/profile/authenticate.php b/views/profile/authenticate.php new file mode 100644 index 0000000..540d4a3 --- /dev/null +++ b/views/profile/authenticate.php @@ -0,0 +1,27 @@ +<?php + +if ($_SERVER['REQUEST_METHOD'] !== 'POST') { + header('Allow: POST'); + http_response_code(405); + header('Content-Type: text/plain'); + echo $_SERVER['REQUEST_METHOD'] . " request not allowed!"; + exit; +} + +include '../meta.php'; + +$user = null; +runController('user'); + +if ($user !== null) { + http_response_code(200); + header('Content-Type: text/plain'); + echo $user->Username; +} +else { + http_response_code(401); + header('Content-Type: text/plain'); + echo 'Bad token!'; +} + +exit; |
