aboutsummaryrefslogtreecommitdiff
path: root/views/profile/authenticate.php
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-01-26 11:08:46 +0200
committerSyndamia <kamen@syndamia.com>2025-01-26 11:09:27 +0200
commit76de68d2f3600a7000a054be3f595029b1931e20 (patch)
tree35a48cde04501c4992d48f6ed32bb31ea9b597b6 /views/profile/authenticate.php
parent723cf2e6cbbea35e8f365d2287d01acb96f02643 (diff)
downloadnowayforward_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.php27
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;