示例#1
0
 public function sendResetLink($data)
 {
     $userDao = new UsersDao();
     $user = $userDao->getUserByParam('email', $data['email']);
     if ($user->isEmpty()) {
         throw new \Exception("Email is not registered");
     }
     $user = $user[0];
     $hash = md5(time() . $user->id . 'ASKLD128fjsdfksfuewqekjsu');
     $user->reset_hash = $hash;
     $user->save();
     // send mail
     $mailService = new MailService();
     $passwordArray = array();
     $passwordArray['to'] = $user->email;
     $passwordArray['user_object'] = $user;
     $webClient = env('WEB_CLIENT');
     $passwordArray['reset_link'] = $webClient . "#/resetpassword/" . $hash;
     $passwordArray['user_object'] = $user;
     $sent = $mailService->resetPasswordMail($passwordArray);
     if ($sent) {
         return "Succesfully sent";
     } else {
         return "Error sending mail";
     }
 }