mirror of
https://github.com/simon987/Much-Assembly-Required-Frontend.git
synced 2025-12-14 07:09:06 +00:00
Major refactor of the console screen, game code rewritten in Typescript, users can now change their passwords
This commit is contained in:
39
changePassword.re.php
Normal file
39
changePassword.re.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
include_once "include/UserManager.php";
|
||||
include_once "include/MessageCookie.php";
|
||||
include_once "include/SessionManager.php";
|
||||
|
||||
$user = SessionManager::get();
|
||||
|
||||
if ($user != NULL) {
|
||||
|
||||
$password = $_POST['password'];
|
||||
$newPassword = $_POST['new_password'];
|
||||
|
||||
if (strlen($newPassword) < 8 || strlen($newPassword) > 96) {
|
||||
|
||||
(new MessageCookie("Password must be 8-96 characters", "register"))->setCookie();
|
||||
header("Location: account.php");
|
||||
} else {
|
||||
|
||||
if (UserManager::auth($user['username'], $password) != NULL) {
|
||||
|
||||
UserManager::changePassword($user['username'], $newPassword);
|
||||
|
||||
header("Location: index.php");
|
||||
|
||||
} else {
|
||||
$msg = new MessageCookie("Invalid password", "register");
|
||||
$msg->setCookie();
|
||||
header("Location: account.php");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$msg = new MessageCookie("You must be logged in to do that", "register");
|
||||
$msg->setCookie();
|
||||
header("Location: account.php");
|
||||
}
|
||||
Reference in New Issue
Block a user