Example #1
0
 /**
  * Activate user account
  * 
  * @param unknown_type $email
  * @param unknown_type $hash
  */
 public function action_activate($email = false, $hash = false)
 {
     $settings = \Config::load('autoresponder.db');
     if ($email && $hash) {
         //Keep existing messages
         \Messages::instance()->shutdown();
         try {
             if ($user = \Sentry::activate_user($email, $hash)) {
                 $email_data = array('site_title' => \Config::get('site_title'), 'customer_name' => ucwords($user->get('metadata.first_name')));
                 // Send email to user
                 $email_sent = \App\Emailer::send_email_to_user($user->email, $email_data['customer_name'], 'Welcome to ' . $settings['website'], '_email/user_register', $email_data);
                 // Send email to admins
                 \App\Emailer::send_email_to_group('register', 'Welcome to ' . $settings['website'], '_email/user_register', $email_data);
                 if ($email_sent) {
                     // \Messages::success('Accout successfully activated. Please login and start using your account.');
                     \Messages::success('Welcome! Your account is now activated. Please log in.');
                 } else {
                     \Messages::error('Error while sending email.');
                 }
             } else {
                 //\Messages::error('<h4>There was an error while trying activate user</h4>');
                 \Messages::error('Wrong activation code. Please check your email and try again.');
             }
         } catch (\Sentry\SentryException $e) {
             // show validation errors
             //\Messages::error('<h4>There was an error while trying activate user</h4>');
             $errors = $e->getMessage();
             \Messages::error($errors);
         }
     }
     \Response::redirect(\Uri::front_create('user/login'));
 }
Example #2
0
 public function get_activate($email = null, $hash = null)
 {
     try {
         $activate_user = Sentry::activate_user($email, $hash);
         if ($activate_user) {
             return Redirect::to('user/login');
         } else {
             echo 'The user was not activated';
         }
     } catch (Sentry\SentryEXception $e) {
         echo $e->getMessage();
     }
 }
Example #3
0
 public function get_activate($hash, $key)
 {
     $activate_user = Sentry::activate_user($hash, $key);
     if ($activate_user) {
         try {
             // Force login
             Sentry::force_login($activate_user->email);
             return View::make('user.activation-complete')->with('error', false);
         } catch (Sentry\SentryException $e) {
             return View::make('user.activation-complete')->with('error', true);
         }
     } else {
         return View::make('user.activation-complete')->with('error', true);
     }
 }
 public function action_address()
 {
     if ($this->check_logged_type() == 'guest') {
         \Sentry::logout();
     }
     if ($this->check_logged()) {
         \Response::redirect(\Uri::create('order/checkout/cost'));
     }
     if (\Input::post('details')) {
         // check for a valid CSRF token
         if (!\Security::check_token()) {
             \Messages::error('CSRF attack or expired CSRF token.');
             \Response::redirect(\Input::referrer(\Uri::create('/')));
         }
         $insert = \Input::post();
         if (!$insert['create_account']) {
             $val = \User\Controller_Validate::forge('guest', false, \Input::post('same_address', 1) ? false : 'shipping');
         } else {
             $val = \User\Controller_Validate::forge('create', false, \Input::post('same_address', 1) ? false : 'shipping');
         }
         if ($val->run()) {
             // Get POST values
             array_walk($insert, create_function('&$val', '$val = trim($val);'));
             try {
                 // Mark user as guest if its that case
                 if (!$insert['create_account']) {
                     $insert['guest'] = 1;
                     $guest = 1;
                     $username = uniqid(time(), true);
                 } else {
                     $username = $insert['email'];
                     $insert['guest'] = 0;
                 }
                 $email = $insert['email'];
                 $password = $insert['password'] ? $insert['password'] : \Str::random('alnum', 10);
                 $user_group = $insert['guest'] ? 3 : 4;
                 unset($insert['details'], $insert['signup'], $insert['user_group'], $insert['username'], $insert['email'], $insert['password'], $insert['confirm_password'], $insert['confirm_email'], $insert['terms'], $insert['create_account'], $insert['same_address'], $insert['fuel_csrf_token']);
                 // create the user - no activation required
                 $vars = array('username' => $username, 'email' => $email, 'password' => $password, 'metadata' => $insert);
                 $user_registration = \Sentry::user()->register($vars);
                 $user = \Sentry::user($user_registration['id']);
                 // Add user to 'customer' group (id = 3)
                 if ($user_registration and $user->add_to_group($user_group)) {
                     // Activate account
                     $activation = explode('/', $user_registration['hash']);
                     \Sentry::activate_user($activation[0], $activation[1]);
                     // Login user and redirect to next page
                     //\Sentry::login($email, $password, true);
                     \Sentry::login($username, $password, true);
                     \Response::redirect(\Uri::front_create('order/checkout/cost'));
                 }
             } 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 {
             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());
                 }
             }
         }
     }
     \Theme::instance()->set_partial('content', $this->view_dir . 'address');
 }
Example #5
0
 }
 /**
  * Activate a new user and log them in
  * @todo Finish email authentication mechanism
  */
 if (FALSE && Config::get('xysti.routes.auth.activate')) {
     Route::get('activate/(:any)/(:any)', function () {
         Xysti::helper('dbug');
         $auth_driver = Config::get('xysti.auth', 'default');
         // Default auth
         if ($auth_driver == 'default') {
             Xysti::error(500, 'Default auth currently not configured for activation.');
             // Sentry auth
         } elseif ($auth_driver == 'sentry') {
             try {
                 $activate_user = Sentry::activate_user(URI::segment(2), URI::segment(3), FALSE);
             } catch (Sentry\SentryException $e) {
                 // issue activating the user
                 // store/set and display caught exceptions such as a suspended user with limit attempts feature.
                 $errors = $e->getMessage();
             }
         } else {
             return Xysti::error(500, 'Unknown authentication driver.');
         }
         if ($activate_user) {
             //Sentry::force_login(URI::segment(2));
             return Redirect::to(Xysti::page('login', 'post_login'));
         } else {
             return Xysti::make(500, 'User activation failed.');
         }
     });