aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 14:09:34 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 14:09:34 +0200
commitf8ffe63ab3b9d16ff03b84d98f20db1b7e525e25 (patch)
tree887dac6380c1897e9087200f25ffec6f451fc3ec /controllers
parent0e4f90e6a82f0fc275d65bf0e4f4c2842052dde9 (diff)
downloadnowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.tar.gz
nowayforward_human-f8ffe63ab3b9d16ff03b84d98f20db1b7e525e25.zip
feat(views/user): Implement account updating (settings)
Diffstat (limited to 'controllers')
-rw-r--r--controllers/user.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/controllers/user.php b/controllers/user.php
index d79b294..ac906a0 100644
--- a/controllers/user.php
+++ b/controllers/user.php
@@ -22,6 +22,43 @@ function on_post() {
}
}
+function on_patch() {
+ global $TOKEN;
+ global $METHOD;
+ global $username_status;
+ global $password_status;
+ $username_status = "";
+ $password_status = "";
+
+ $status = null;
+ switch ($METHOD['type']) {
+ case 'username': $status = 'username_status'; break;
+ case 'password': $status = 'password_status'; break;
+ default: throw new Exception('Invalid patch type ' . $METHOD['type']);
+ }
+
+ $user = null;
+ try {
+ $user = Database\Cookie::fromDB($TOKEN);
+ }
+ catch(Exception $e) {
+ $$status = "Couldn't retrieve user!";
+ return;
+ }
+
+ switch ($METHOD['type']) {
+ case 'username':
+ $user->update($METHOD['username']);
+ header('Location: /user/' . $METHOD['username']);
+ break;
+ case 'password':
+ $user->update($user->Username, $METHOD['password']);
+ header('Location: /user/' . $user->Username);
+ break;
+ }
+ exit();
+}
+
function on_delete() {
global $TOKEN;
global $METHOD;