示例#1
0
 /** 
  * Generates a new random password and creates a new Notification item
  */
 public function actionRetrieve($id, $redirect)
 {
     $model = $this->loadModel($id);
     $new_pass = Users::model()->generatePassword();
     $model->attributes = array('password' => Users::model()->hashPassword($new_pass));
     $model->save();
     //Notification
     Notifications::generate('Users', $model->username, 'users', 'retrieve', $new_pass);
     if ($redirect == 'admin') {
         Yii::app()->user->setFlash('success', Yii::t('user', 'The new password is generated and was sent to user e-mail.'));
     } else {
         Yii::app()->user->setFlash('retrieve', Yii::t('user', 'The new password is generated and was sent to your e-mail.'));
     }
     $this->redirect(array($redirect));
 }
示例#2
0
 /** 
  * Generates a new random password and creates a new Notification item
  */
 public function actionRetrieve()
 {
     $model = new LoginForm();
     if (isset($_POST['LoginForm'])) {
         $user = Users::model()->findByPk($_POST['LoginForm']['username']);
         if ($user === null) {
             $model->addError('username', Yii::t('user', 'Username not valid'));
         } else {
             $new_pass = Users::model()->generatePassword();
             $user->attributes = array('password' => Users::model()->hashPassword($new_pass));
             $user->save();
             //Notification
             Notifications::generate('Users', $user->username, 'users', 'retrieve', $new_pass);
             // display the login form
             Yii::app()->user->setFlash('retrieve', 'The new password was sent to you via email.');
             $this->redirect(array('login'));
         }
     }
     // display the retrieve form
     $this->render('retrieve', array('model' => $model));
 }
示例#3
0
文件: Users.php 项目: Gnafu/wiz
 /** 
  * This method is invoked after saving a record.
  * It creates a new Notification item
  */
 public function afterSave()
 {
     //perform this operation only in the first save
     if ($this->isNewRecord && $this->role->name == 'planner') {
         //Notification
         Notifications::generate('Users', $this->username, 'users', 'create');
     }
     return parent::afterSave();
 }