public function actionReset($code)
 {
     $code = Reset::find()->where(['code' => $code, 'used' => 0])->andWhere(['>', 'expires', time()])->one();
     if (!$code) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     $model = new ResetPasswordForm($code->user_id);
     $model->load(Yii::$app->getRequest()->getBodyParams(), '');
     if ($model->save() === false && !$model->hasErrors()) {
         throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
     }
     $code->used = 1;
     $code->save();
     return $model;
 }
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = ['current_password', 'required'];
     $rules[] = ['current_password', function () {
         if (!$this->user->validatePassword($this->current_password)) {
             $this->addError('current_password', 'Current password is incorrect.');
         }
     }];
     return $rules;
 }