示例#1
0
 public function post_reset()
 {
     $errors = new Laravel\Messages();
     $input = Input::get();
     try {
         $validator = new Services\Session\Reset\Validator($input);
         $validator->publish();
     } catch (ValidateException $errors) {
         return Redirect::to(URL::to_route('session.reset'))->with_input()->with_errors($errors->get());
     }
     try {
         $reset = Sentry::reset_password(Input::get('email'), Input::get('password'));
         if (!$reset) {
             $errors->add('errors', __('application.resset_error'));
             return Redirect::to(URL::to_route('session.reset'))->with_input()->with_errors($errors);
         }
     } catch (Sentry\SentryException $e) {
         $errors->add('errors', $e->getMessage());
         return Redirect::to(URL::to_route('session.reset'))->with_input()->with_errors($errors);
     }
     $errors = new Laravel\Messages();
     try {
         $message = Message::to(Input::get('email'))->from(Config::get('app.email_address'), 'cubanartjb')->subject('Reset Password!')->body('Here\'s your link: ' . URL::base() . '/session/confirmation/' . $reset['link'])->send();
         if ($message->was_sent()) {
             return Redirect::to(URL::to_route('session.login'))->with('status_success', __('application.reset_confirm_link'));
         } else {
             $errors->add('errors', __('application.email_error'));
             return Redirect::to(URL::to_route('session.reset'))->with_input()->with_errors($errors);
         }
     } catch (\Exception $e) {
         $errors->add('errors', $e->getMessage());
         return Redirect::to(URL::to_route('session.reset'))->with_input()->with_errors($errors);
     }
     // return View::make('session/reset_confirmation')
     // ->with('title', HtmlHelpers::name('Reset Confirmation'))
     // ->with('hash_link', URL::base().'/session/confirmation/'.$reset['link']);
 }