本文整理匯總了PHP中UserDB::getBasicUserByEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserDB::getBasicUserByEmail方法的具體用法?PHP UserDB::getBasicUserByEmail怎麽用?PHP UserDB::getBasicUserByEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserDB
的用法示例。
在下文中一共展示了UserDB::getBasicUserByEmail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: post
public static function post()
{
$page = new Page();
$page->data['title'] = 'Wachtwoord resetten';
$errMsgs = ResetPasswordViewValidator::validate($_POST);
if (empty($errMsgs)) {
try {
//Get the user's password salt and calculate password hash
$passwordSalt = UserDB::getPasswordSaltByEmail($_POST['email']);
$newPassword = Random::getPassword();
$newPasswordHash = hash_pbkdf2('sha256', $newPassword, $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS);
//Get user from database and reset password.
$user = UserDB::getBasicUserByEmail($_POST['email']);
UserDB::resetPassword($_POST['email'], $newPasswordHash);
//Show success message
$page->data['ResetSuccessfulView']['redirectUrl'] = 'login';
$page->addView('resetPassword/ResetSuccessfulView');
//Send email with password
$failedEmails = Email::sendEmails('ResetPassword.html', 'JH De Stip - Wachtwoord reset', EmailConfig::FROM_ADDRESS, [$user], array($user->userId => array('newPassword' => $newPassword)));
//If failedEmails is not empty the mail was not sent
if (!empty($failedEmails)) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail met nieuwe wachtwoord niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
}
} catch (UserDBException $ex) {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs'] = ResetPasswordViewValidator::initErrMsgs();
if ($ex->getCode() == UserDBException::NOUSERFOREMAIL) {
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Er is geen gebruiker met dit e-mailadres.</h2>';
} else {
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Kan wachtwoord niet resetten, probeer het opnieuw.</h2>';
}
$page->addView('resetPassword/ResetPasswordView');
} catch (EmailException $ex) {
$page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan e-mail met nieuwe wachtwoord niet verzenden.';
$page->addView('error/ErrorMessageNoDescriptionNoLinkView');
} catch (Exception $ex) {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs']['global'] = '<h2 class="error_message" id="reset_password_form_error_message">Kan wachtwoord niet resetten, probeer het opnieuw.</h2>';
$page->addView('resetPassword/ResetPasswordView');
}
} else {
$page->data['ResetPasswordView']['reset_password_formAction'] = $_SERVER['REQUEST_URI'];
$page->data['ResetPasswordView']['email'] = $_POST['email'];
$page->data['ResetPasswordView']['errMsgs'] = ResetPasswordViewValidator::initErrMsgs();
$page->data['ResetPasswordView']['errMsgs'] = array_merge($page->data['ResetPasswordView']['errMsgs'], $errMsgs);
$page->addView('resetPassword/ResetPasswordView');
}
$page->showWithMenu();
}