Exemple #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']);
 }
Exemple #2
0
 /**
  * Change user password
  * 
  * @access public
  * @return void
  */
 public function action_password()
 {
     \View::set_global('title', 'Forgot Password');
     if (\Input::post('forgot')) {
         $val = \User\Controller_Validate::forge('forgot_password');
         if ($val->run()) {
             // Get POST values
             $identity = \Input::post('identity', '');
             if (\Sentry::user_exists($identity)) {
                 try {
                     // reset the password
                     $reset = \Sentry::reset_password($identity);
                     if ($reset) {
                         $customer_email = $reset['email'];
                         // Load email package
                         \Package::load('email');
                         // Load email addresses from config (these will be bcc receivers)
                         \Config::load('auto_response_emails', true);
                         $bcc = \Config::get('autoresponders.forgot_password_emails');
                         if (!$bcc) {
                             $bcc = \Config::get('autoresponders.default_emails');
                         }
                         $settings = \Config::load('autoresponder.db');
                         $email_data = array('site_title' => $settings['company_name'], 'customer_identity' => $identity, 'reset_link' => \Uri::front_create('user/reset_password/' . $reset['link']));
                         $email = \Email::forge();
                         $email->to($customer_email);
                         $email->from(\Config::get('auto_response_emails.autoresponder_from_email'), $settings['company_name']);
                         if ($bcc) {
                             $email->bcc($bcc);
                         }
                         $email->subject($email_data['site_title'] . ' - Forgot Password');
                         $email_html = \Theme::instance()->view('views/_email/forgot_password')->set('email_data', $email_data, false);
                         $email->html_body($email_html);
                         try {
                             $email->send();
                             \Messages::success('You have been sent an email to reset your password.');
                         } catch (\EmailValidationFailedException $e) {
                             \Messages::error('Error while sending email.');
                         } catch (\EmailSendingFailedException $e) {
                             \Messages::error('Error while sending email.');
                         }
                         \Response::redirect(\Input::referrer(\Uri::front_create('/')));
                     } else {
                         \Messages::error('There was a problem while trying to change your password. Please try again.');
                     }
                 } catch (\Sentry\SentryException $e) {
                     // show validation errors
                     //\Messages::error('<h4>There was an error while trying to create user</h4>');
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             } else {
                 \Messages::error('There doesn`t appear to be an account associated with this email address. Try a different email address or register for a new account on the homepage.');
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 //\Messages::error('<h4>There was an error while trying to create user</h4>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     if (\Input::is_ajax()) {
         echo \Theme::instance()->view($this->view_dir . 'forgot_password');
     } else {
         if (isset($val)) {
             \View::set_global('validation', $val, false);
         }
         \Theme::instance()->set_partial('content', $this->view_dir . 'single_forgot_password');
     }
 }
 public function post_reset()
 {
     // data pass to the view
     $data = array();
     // do valiation
     $rules = array('email' => 'required|email', 'password' => 'required|confirmed', 'password_confirmation' => 'required');
     $input = Input::get();
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to('user/reset')->with_input()->with_errors($validation);
     }
     // add user
     try {
         $reset = Sentry::reset_password(Input::get('email'), Input::get('password'));
         if (!$reset) {
             $data['errors'] = 'There was an issue when reset the password';
         }
     } catch (Sentry\SentryException $e) {
         $data['errors'] = $e->getMessage();
     }
     if (array_key_exists('errors', $data)) {
         return Redirect::to('user/reset')->with_input()->with('errors', $data['error']);
     } else {
         return Redirect::to('user/login')->with('hash_link', URL::base() . '/user/confirmation/' . $reset['link']);
     }
 }