当前位置: 首页>>代码示例>>PHP>>正文


PHP UserController::generatePassword方法代码示例

本文整理汇总了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
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:31,代码来源:AjaxRegisterAction.php

示例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
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:32,代码来源:AjaxForgotAction.php


注:本文中的UserController::generatePassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。