Example #1
0
 /**
  * Trigger 'forgot password' email
  */
 public function forgotPassword()
 {
     $data = $this->getData();
     $auth = Auth::where('email', $data['email'])->first();
     if (!$auth) {
         throw new Exceptions\NotFoundException("invalid_user");
     }
     if (!isset($data['subject'])) {
         $data['subject'] = 'Forgot your password?';
     }
     $body_data = Context::unsafe(function () use(&$auth) {
         $array = $auth->generateForgotPasswordToken()->toArray();
         $array['token'] = $auth->getAttribute(Auth::FORGOT_PASSWORD_FIELD);
         return $array;
     });
     $template = isset($data['template']) ? $data['template'] : self::TEMPLATE_FORGOT_PASSWORD;
     return array('success' => Mail::send(array('subject' => $data['subject'], 'from' => Config::get('mail.from', '*****@*****.**'), 'to' => $auth->email, 'body' => Module::template($template)->compile($body_data))) === 1);
 }