Ejemplo n.º 1
0
 /**
  * @param Admin $user
  * @return bool
  */
 public function changePassword(Admin $user)
 {
     if ($this->validate()) {
         $user->setPassword($this->newPassword);
         return $user->save();
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Finds the Admin model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Admin the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Admin::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Admin::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'passwordResetExpire' => $this->passwordResetExpire, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'lastName', $this->lastName])->andFilterWhere(['like', 'passwordHash', $this->passwordHash])->andFilterWhere(['like', 'passwordResetToken', $this->passwordResetToken])->andFilterWhere(['like', 'authKey', $this->authKey])->andFilterWhere(['like', 'emailConfirmToken', $this->emailConfirmToken]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 public function actionReset($id, $token = false)
 {
     /** @var Admin $user */
     $user = Admin::findOne($id);
     if ($token !== false && isset($user) && $user->passwordResetToken === $token && $user->passwordResetExpire >= time()) {
         $model = new PasswordResetForm();
         if ($model->load(Yii::$app->getRequest()->post()) && $model->changePassword($user)) {
             Yii::$app->user->login($user);
             return $this->redirect(['index']);
         }
         return $this->render('password-reset', ['model' => $model]);
     }
     throw new NotFoundHttpException();
 }
Ejemplo n.º 5
0
    <?php 
echo $form->field($model, 'password')->passwordInput();
?>

    <?php 
if (Yii::$app->getModule('admin')->enableRbac) {
    ?>
        <?php 
    echo $form->field($model, 'role')->dropDownList(Yii::$app->getModule('admin')->get('roleContainer')->getTitles());
    ?>
    <?php 
}
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(Admin::getStatuses());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('admin', 'Create') : Yii::t('admin', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>