Exemple #1
0
 /**
  * @param $email
  * @return bool|mixed
  * @throws \Exception
  */
 public function forgotPassword($email)
 {
     $userModel = new User();
     $emailService = new mailService();
     if (!Validator::make(['email' => $email], ['email' => 'required|email'])) {
         throw new \Exception('Email is not format');
     }
     $user = $this->getUserByEmail($email);
     $data = array();
     $data['temp_password'] = md5($user->password . time());
     $data['temp_password_expire'] = date('Y-m-d H:i:s', strtotime('+1 day'));
     // expire 1 day
     $user = $userModel->updateItem($user->id, $data);
     if ($user) {
         $emailService->sendEmailForgotPassword($email);
         return $user;
     }
     return false;
 }