public function actionForgot()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new ForgotForm();
     if ($model->load(Yii::$app->request->post()) && $model->find()) {
         $user = $model->find();
         $user->generatePasswordResetToken();
         if ($user->save()) {
             $email = Yii::$app->mailer->compose('reset', ['names' => $user->names, 'url' => Yii::$app->urlManager->createAbsoluteUrl(['site/reset', 'token' => $user->password_reset_token])])->setFrom('*****@*****.**')->setTo($user->username)->setSubject($user->names . " " . "Resetea tu cuenta en chaide")->send();
             if ($email) {
                 Yii::$app->getSession()->setFlash('success', 'No te olvides de revisar en la bandeja de spam.');
             } else {
                 Yii::$app->getSession()->setFlash('warning', 'Un error ha ocurrido por favor contactate con soporte técnico.');
             }
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('warning', 'Un error ha ocurrido por favor contactate con soporte técnico.');
             return $this->goHome();
         }
     }
     return $this->render('forgot', ['model' => $model]);
 }
 /**
  * [actionForgot description]
  * @return [type] [description]
  */
 public function actionForgot()
 {
     $model = new ForgotForm();
     $session = new Session();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $getEmail = $model->email;
         $getIdentity = User::find()->where(['email' => $getEmail])->one();
         $getToken = rand(0, 99999);
         $getTime = date("H:i:s");
         $calcToken = md5($getToken . $getTime);
         $getIdentity->token = $calcToken;
         $getEmail = "*****@*****.**";
         $emailAdmin = "*****@*****.**";
         $senderName = "Jobocracy";
         $senderName = '=?UTF-8?B?' . base64_encode($senderName) . '?=';
         $subject = "Reset Password";
         $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
         $message = 'You have successfully reset your password<br>
                    <a href="localhost/application/basic/web/index.php?r=site/ver-token&token=' . $calcToken . '">Click Here to Reset Your Password</a>';
         $headers = "From: {$senderName} <{$emailAdmin}>\r\n" . "Reply To: {$emailAdmin}\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8";
         $getIdentity->save();
         $session->setFlash('forgot', 'A link to reset your password
             has been sent to your email address.');
         mail($getEmail, $subject, $message, $headers);
         return $this->render('forgot', ['session' => $session]);
     }
     return $this->render('forgot', ['model' => $model, 'session' => $session]);
 }