本文整理汇总了PHP中MainController::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MainController::getInstance方法的具体用法?PHP MainController::getInstance怎么用?PHP MainController::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainController
的用法示例。
在下文中一共展示了MainController::getInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateNewEmail
/**
* Validate the new email for a user
*/
public function validateNewEmail()
{
$tokenData = json_decode(Crypto::aes256Decode(base64_decode($this->token)), true);
try {
if (!$tokenData) {
// Token format is not valid
throw new \Exception();
}
$user = User::getById($tokenData['userId']);
if ($user->email !== $tokenData['currentEmail']) {
// Token does not have the correct email corresponding to the user email
throw new \Exception();
}
if ($tokenData['createTime'] < time() - 86400) {
// Token has expired
throw new \Exception();
}
// Everything OK, change the user's email address
$user->set('email', $tokenData['newEmail']);
$user->save();
// Disconnect the user
session_destroy();
$status = 'success';
$messageKey = 'main.reset-email-success';
} catch (\Exception $e) {
$messageKey = 'main.reset-email-invalid-token';
$status = 'error';
}
$this->addJavaScriptInline('
require(["app"], function(){
app.notify("' . $status . '", "' . addcslashes(Lang::get($messageKey), '"') . '");
});');
return MainController::getInstance()->main();
}