Ejemplo n.º 1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = UserFrontend::findByEmail($this->email);
     }
     return $this->_user;
 }
Ejemplo n.º 2
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new UserFrontend();
         $user->status = UserFrontend::STATUS_CONFIRM_NEED;
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         } else {
             Yii::$app->getSession()->setFlash('error', 'User not added');
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('Password reset token cannot be blank.');
     }
     $this->_user = UserFrontend::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException('Wrong password reset token.');
     }
     parent::__construct($config);
 }
Ejemplo n.º 4
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function AcceptConsentProcessingPersonalData()
 {
     $id = Yii::$app->getUser()->getId();
     $user = UserFrontend::findIdentity($id);
     if ($this->validate() and !empty($user)) {
         $user->consent_processing_personal_data = $this->consent_processing_personal_data;
         if ($user->save()) {
             return $user;
         } else {
             Yii::$app->getSession()->setFlash('error', 'Error accept agreement');
         }
     }
     return null;
 }
 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = UserFrontend::findOne(['status' => UserFrontend::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!UserFrontend::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function update()
 {
     $id = Yii::$app->getUser()->getId();
     $user = UserFrontend::findIdentity($id);
     if ($this->validate() and isset($user)) {
         $user->username = $this->username;
         if (!empty($this->password)) {
             $user->setPassword($this->password);
         }
         if ($user->save()) {
             return $user;
         } else {
             Yii::$app->getSession()->setFlash('error', 'not save user settings');
         }
     }
     return null;
 }
Ejemplo n.º 7
0
 /**
  * Abitur application export to pdf.
  *
  * @return mixed
  * @throws BadRequestHttpException
  */
 public function actionProfileToPdf()
 {
     $id = Yii::$app->getUser()->getId();
     $user = UserFrontend::findIdentity($id);
     $profile = Profile::findById($user->id_profile);
     // get your HTML raw content without any layouts or scripts
     //        $content = $this->renderPartial('abiturApplicationToPdf', ['model'=>$profile]);
     $content = $this->renderPartial('profileToPdf', ['model' => $profile]);
     // setup kartik\mpdf\Pdf component
     $pdf = new Pdf(['mode' => Pdf::MODE_CORE, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'mode' => Pdf::MODE_UTF8, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Заявление'], 'methods' => [], 'marginLeft' => 30, 'marginRight' => 15, 'marginTop' => 12, 'marginBottom' => 12]);
     // return the pdf output as per the destination setting
     return $pdf->render();
 }
Ejemplo n.º 8
0
 /**
  * Requests confirm email.
  *
  * @return mixed
  */
 public function actionNewEmailConfirm($token)
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException('New email token cannot be blank.');
     }
     $user = UserFrontend::findByNewEmailToken($token);
     if (!empty($user)) {
         $user->status = UserFrontend::STATUS_ACTIVE;
         $user->save();
         Yii::$app->getSession()->setFlash('success', 'Успешно! Email адрес подтвержден.');
     } else {
         Yii::$app->getSession()->setFlash('warning', 'Wrong password reset token.!');
         //throw new InvalidParamException('Wrong password reset token.');
     }
     return $this->goHome();
 }