本文整理汇总了PHP中UserController::generatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserController::generatePassword方法的具体用法?PHP UserController::generatePassword怎么用?PHP UserController::generatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserController
的用法示例。
在下文中一共展示了UserController::generatePassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$form = new AjaxRegisterAction_RegisterForm();
$form->name = $_REQUEST['popup_username'];
$form->email = $_REQUEST['popup_email'];
if ($form->validate()) {
$user = new User();
$user->name = $form->name;
$user->mail = $form->email;
$user->type = User::TYPE_INDIVIDUAL;
$user->created = time();
$user->status = User::STATUS_NOT_CONFIRMED;
// Change password to a new one
Yii::import('webroot.controllers.UserController');
$generatedPass = UserController::generatePassword();
$user->pass = md5($generatedPass);
$user->save(false);
// Mail the user
if (Mailer::mailFastRegister($user, $generatedPass, $form->email)) {
$result = array("result" => 0, "message" => Yii::t('amo', 'Email sent!!'));
} else {
$result = array("result" => -1, "message" => Yii::t('amo', 'Error sending email'));
}
} else {
$errors = $form->getErrors('email');
$result = array("result" => -1, "message" => implode(", ", $errors));
}
echo CJSON::encode($result);
exit(0);
// To avoid loggers append things to request
}
示例2: run
public function run()
{
$form = new AjaxForgotAction_ForgotForm();
$form->email = $_REQUEST['popup_email'];
if ($form->validate()) {
$user = User::model()->find('mail=:mail', array(':mail' => $form->email));
if (isset($user)) {
// Change password to a new one
Yii::import('webroot.controllers.UserController');
$generatedPass = UserController::generatePassword();
$user->pass = md5($generatedPass);
if ($user->save(false)) {
// Mail the user
if (Mailer::mailForgotPassword($generatedPass, $form->email)) {
$result = array("result" => 0, "message" => Yii::t('amo', 'Email sent!!'));
} else {
$result = array("result" => -1, "message" => Yii::t('amo', 'Error sending email'));
}
} else {
$result = array("result" => -1, "message" => Yii::t('amo', 'Could not save to database'));
}
} else {
$result = array("result" => -1, "message" => Yii::t('amo', 'There is no user with such email'));
}
} else {
$errors = $form->getErrors('email');
$result = array("result" => -1, "message" => implode(", ", $errors));
}
echo CJSON::encode($result);
exit(0);
// To avoid loggers append things to request
}