diff options
| -rw-r--r-- | controllers/user.php | 4 | ||||
| -rw-r--r-- | views/user/create/index.php | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/controllers/user.php b/controllers/user.php index bc3da70..1bc91cc 100644 --- a/controllers/user.php +++ b/controllers/user.php @@ -5,6 +5,7 @@ use Exception; function on_post() { global $user_status; + global $token; $user_status = ""; try { @@ -15,7 +16,8 @@ function on_post() { catch(Exception $e) {} try { - Database\User::create($_POST["username"], $_POST["password"], "User"); + $uid = Database\User::create($_POST["username"], $_POST["password"], "User"); + $token = Database\Cookie::create($uid); } catch(Exception $e) { $user_status = $e; diff --git a/views/user/create/index.php b/views/user/create/index.php index 223ab9b..658d5de 100644 --- a/views/user/create/index.php +++ b/views/user/create/index.php @@ -12,6 +12,10 @@ <p class="item success"> Success! </p> + <script type="text/javascript"> + cookieStorage.setItem("token", "<?= $token ?>"); + window.location.href = "/"; + </script> <?php endif; ?> <?php endif; ?> |
