Update return types

This commit is contained in:
Valithor Obsidion 2025-08-14 16:53:51 -04:00
parent d40b826dfa
commit f0fc0f257b

View File

@ -45,7 +45,7 @@ class Users
/**
* Displays the login page, and processes login requests.
*/
public static function login()
public static function login(): string|false
{
global $auth;
@ -75,7 +75,7 @@ class Users
/**
* Delete the current cookie and redirect to home.
*/
public static function logout()
public static function logout(): void
{
global $auth;
$auth->logout();
@ -85,7 +85,7 @@ class Users
/**
* Register a new account.
*/
public static function register()
public static function register(): string|false
{
if (isset($_POST['submit'])) {
$form = validate($_POST, [
@ -133,7 +133,7 @@ class Users
return $page;
}
public static function verify()
public static function verify(): string|false
{
if (isset($_POST['submit'])) {
$u = trim($_POST['username'] ?? '');
@ -153,7 +153,7 @@ class Users
return render('verify');
}
public static function lostpassword()
public static function lostpassword(): string|false
{
if (isset($_POST['submit'])) {
$e = trim($_POST['email'] ?? '');
@ -177,11 +177,12 @@ class Users
return render('lostpassword');
}
public static function changepassword()
public static function changepassword(): string|false
{
global $auth;
if (! isset($_POST['submit'])) {
return false;
}
if (isset($_POST['submit'])) {
$u = trim($_POST['username'] ?? '');
$p = $_POST['password'] ?? '';
$np = $_POST['new_password'] ?? '';
@ -208,15 +209,18 @@ class Users
$realnewpass = password_hash($np, PASSWORD_ARGON2ID);
db()->query('UPDATE users SET password=? WHERE username=?;', [$realnewpass, $u]);
global $auth;
$auth->logout();
return 'Your password was changed successfully.<br><br>You have been logged out of the game to avoid errors.<br><br>Please <a href="/login">log back in</a> to continue playing.';
}
public static function settings(): string|false
{
if (! is_post()) {
return render('settings');
}
public static function settings()
{
if (is_post()) {
$form = validate($_POST, [
'game_skin' => ['in:0,1'],
]);
@ -233,10 +237,7 @@ class Users
return $alert.render('settings');
}
return render('settings');
}
public static function sendpassemail($emailaddress, $password)
public static function sendpassemail($emailaddress, $password): bool
{
$email = <<<HTML
You or someone using your email address submitted a Lost Password application on the {env('game_name')} server, located at {env('game_url')}.
@ -251,7 +252,7 @@ class Users
return Mail::send_email($emailaddress, env('game_name').' Lost Password', $email);
}
public static function sendregmail($emailaddress, $vercode)
public static function sendregmail($emailaddress, $vercode): bool
{
$verurl = env('game_url').'/verify';