mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* account management rework: Personal Settings functionality * email, password, username update * email updates now also mails the old address for confirmation
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Aowow;
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
|
|
/*
|
|
* accessed via revert email link
|
|
* write status to session and redirect to account settings
|
|
*/
|
|
|
|
// ?auth=email-revert
|
|
class AccountRevertemailaddressResponse extends TemplateResponse
|
|
{
|
|
protected string $template = 'text-page-generic';
|
|
protected string $pageName = 'revert-email-address';
|
|
|
|
protected array $expectedGET = array(
|
|
'key' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[a-zA-Z0-9]{40}$/']]
|
|
);
|
|
|
|
private bool $success = false;
|
|
|
|
protected function generate() : void
|
|
{
|
|
parent::generate();
|
|
|
|
if (User::isBanned())
|
|
return;
|
|
|
|
$msg = $this->revert();
|
|
|
|
$this->inputbox = ['inputbox-status', array(
|
|
'head' => Lang::account('inputbox', 'head', $this->success ? 'success' : 'error'),
|
|
'message' => $this->success ? $msg : '',
|
|
'error' => $this->success ? '' : $msg,
|
|
)];
|
|
}
|
|
|
|
// this should probably take precedence over email-change
|
|
// todo - move personal settings changes to separate table
|
|
private function revert() : string
|
|
{
|
|
if (!$this->assertGET('key'))
|
|
return Lang::main('intError');
|
|
|
|
$acc = DB::Aowow()->selectRow('SELECT `updateValue`, `status`, `statusTimer` FROM ?_account WHERE `token` = ?', $this->_get['key']);
|
|
if (!$acc || $acc['status'] != ACC_STATUS_CHANGE_EMAIL || $acc['statusTimer'] < time())
|
|
return Lang::account('inputbox', 'error', 'mailTokenUsed');
|
|
|
|
// 0 changes == error
|
|
if (!DB::Aowow()->query('UPDATE ?_account SET `status` = ?d, `statusTimer` = 0, `token` = "", `updateValue` = "" WHERE `token` = ?', ACC_STATUS_NONE, $this->_get['key']))
|
|
return Lang::main('intError');
|
|
|
|
$this->success = true;
|
|
return Lang::account('inputbox', 'message', 'mailRevertOk');
|
|
}
|
|
}
|
|
|
|
?>
|