forked from Sky/Dragon-Knight
Update return types
This commit is contained in:
parent
d40b826dfa
commit
f0fc0f257b
@ -45,7 +45,7 @@ class Users
|
|||||||
/**
|
/**
|
||||||
* Displays the login page, and processes login requests.
|
* Displays the login page, and processes login requests.
|
||||||
*/
|
*/
|
||||||
public static function login()
|
public static function login(): string|false
|
||||||
{
|
{
|
||||||
global $auth;
|
global $auth;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class Users
|
|||||||
/**
|
/**
|
||||||
* Delete the current cookie and redirect to home.
|
* Delete the current cookie and redirect to home.
|
||||||
*/
|
*/
|
||||||
public static function logout()
|
public static function logout(): void
|
||||||
{
|
{
|
||||||
global $auth;
|
global $auth;
|
||||||
$auth->logout();
|
$auth->logout();
|
||||||
@ -85,7 +85,7 @@ class Users
|
|||||||
/**
|
/**
|
||||||
* Register a new account.
|
* Register a new account.
|
||||||
*/
|
*/
|
||||||
public static function register()
|
public static function register(): string|false
|
||||||
{
|
{
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$form = validate($_POST, [
|
$form = validate($_POST, [
|
||||||
@ -133,7 +133,7 @@ class Users
|
|||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function verify()
|
public static function verify(): string|false
|
||||||
{
|
{
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$u = trim($_POST['username'] ?? '');
|
$u = trim($_POST['username'] ?? '');
|
||||||
@ -153,7 +153,7 @@ class Users
|
|||||||
return render('verify');
|
return render('verify');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function lostpassword()
|
public static function lostpassword(): string|false
|
||||||
{
|
{
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$e = trim($_POST['email'] ?? '');
|
$e = trim($_POST['email'] ?? '');
|
||||||
@ -177,11 +177,12 @@ class Users
|
|||||||
return render('lostpassword');
|
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'] ?? '');
|
$u = trim($_POST['username'] ?? '');
|
||||||
$p = $_POST['password'] ?? '';
|
$p = $_POST['password'] ?? '';
|
||||||
$np = $_POST['new_password'] ?? '';
|
$np = $_POST['new_password'] ?? '';
|
||||||
@ -208,15 +209,18 @@ class Users
|
|||||||
$realnewpass = password_hash($np, PASSWORD_ARGON2ID);
|
$realnewpass = password_hash($np, PASSWORD_ARGON2ID);
|
||||||
db()->query('UPDATE users SET password=? WHERE username=?;', [$realnewpass, $u]);
|
db()->query('UPDATE users SET password=? WHERE username=?;', [$realnewpass, $u]);
|
||||||
|
|
||||||
|
global $auth;
|
||||||
$auth->logout();
|
$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.';
|
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, [
|
$form = validate($_POST, [
|
||||||
'game_skin' => ['in:0,1'],
|
'game_skin' => ['in:0,1'],
|
||||||
]);
|
]);
|
||||||
@ -233,10 +237,7 @@ class Users
|
|||||||
return $alert.render('settings');
|
return $alert.render('settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
return render('settings');
|
public static function sendpassemail($emailaddress, $password): bool
|
||||||
}
|
|
||||||
|
|
||||||
public static function sendpassemail($emailaddress, $password)
|
|
||||||
{
|
{
|
||||||
$email = <<<HTML
|
$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')}.
|
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);
|
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';
|
$verurl = env('game_url').'/verify';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user