本文整理汇总了PHP中Notifier::forgotPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::forgotPassword方法的具体用法?PHP Notifier::forgotPassword怎么用?PHP Notifier::forgotPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifier
的用法示例。
在下文中一共展示了Notifier::forgotPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forgot_password
/**
* Render and process forgot password form
*
* @param void
* @return null
*/
function forgot_password()
{
if (isset($_GET['your_email'])) {
$your_email = trim(array_var($_GET, 'your_email'));
} else {
$your_email = trim(array_var($_POST, 'your_email'));
}
tpl_assign('your_email', $your_email);
if (array_var($_REQUEST, 'submited') == 'submited') {
if (!is_valid_email($your_email)) {
tpl_assign('error', new InvalidEmailAddressError($your_email, lang('invalid email address')));
$this->render();
}
// if
$user = Contacts::getByEmail($your_email);
if (!($user instanceof Contact && $user->isUser()) || $user->getDisabled()) {
flash_error(lang('email address not in use', $your_email));
$this->redirectTo('access', 'forgot_password');
}
// if
$token = sha1(gen_id() . (defined('SEED') ? SEED : ''));
$timestamp = time() + 60 * 60 * 24;
set_user_config_option('reset_password', $token . ";" . $timestamp, $user->getId());
try {
DB::beginWork();
Notifier::forgotPassword($user, $token);
flash_success(lang('success forgot password'));
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error forgot password'));
}
// try
$this->redirectTo('access', 'forgot_password', array('instructions_sent' => 1));
}
// if
}
示例2: forgot_password
/**
* Render and process forgot password form
*
* @param void
* @return null
*/
function forgot_password()
{
$your_email = trim(array_var($_POST, 'your_email'));
tpl_assign('your_email', $your_email);
if (array_var($_POST, 'submitted') == 'submitted') {
if (!is_valid_email($your_email)) {
tpl_assign('error', new InvalidEmailAddressError($your_email, lang('invalid email address')));
$this->render();
}
// if
$user = Users::getByEmail($your_email);
if (!$user instanceof User) {
flash_error(lang('email address not in use', $your_email));
$this->redirectTo('access', 'forgot_password');
}
// if
try {
Notifier::forgotPassword($user);
flash_success(lang('success forgot password'));
} catch (Exception $e) {
flash_error(lang('error forgot password'));
}
// try
$this->redirectTo('access', 'forgot_password');
}
// if
}