本文整理汇总了PHP中UserHelper::generateRandomPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserHelper::generateRandomPassword方法的具体用法?PHP UserHelper::generateRandomPassword怎么用?PHP UserHelper::generateRandomPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserHelper
的用法示例。
在下文中一共展示了UserHelper::generateRandomPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionResetPassword
/**
* Generates a new random password and then send it via email to the user.
*/
public function actionResetPassword()
{
$model = new ResetPasswordForm();
$success = false;
$email = '';
if (isset($_POST['ResetPasswordForm'])) {
$model->attributes = $_POST['ResetPasswordForm'];
$this->performAjaxValidation($model);
$user = User::model()->findByAttributes(array('email' => $model->email));
if (isset($user)) {
$email = $user->email;
$password_clear = UserHelper::generateRandomPassword();
$user->password = $user->changeAccountPassword($password_clear);
if ($user->save()) {
/* write an INFO syslog */
BasicNotifier::sendTemplatedEmail($user->email, Yii::t('UsersModule.resetPassword', 'email.subject'), 'users/account_reset_password', array('{USER_PASSWORD}' => $password_clear), Yii::app()->session['lang']);
$success = true;
}
}
}
$this->render('resetPassword', array('model' => $model, 'success' => $success, 'email' => $email));
}
示例2: control_efetuar_cadastro
public function control_efetuar_cadastro()
{
$this->titulo = 'Cadastre-se';
if ($this->isPostRequest) {
$senhaTemporaria = UserHelper::generateRandomPassword();
try {
$d = new Usuarios($_POST);
$this->em->persist($d);
$this->em->flush();
} catch (Exception $ex) {
$this->adicionarMensagemErro('Ocorreu um erro com seu cadastro, por favor verifique todos os campos');
$this->adicionarMensagemErro($ex->getMessage());
return $this->renderizar('cadastro', array('usuario' => $d));
}
$this->mailer->enviaEmail(array('Usuário' => $d->getEmail(), 'Senha' => $_POST['senha'], 'nome' => $d->getNome()), $d->getEmail(), 'Seja bem vindo(a) ' . $d->getNome(), 'email_pos_cadastro');
return $this->redirect('cadastro-sucesso/');
}
return $this->redirect('home');
}