Guest User

Untitled

a guest
Nov 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // Where all visitors can access
  2. $allowed_routes = array(
  3. 'product/category',
  4. 'common/home',
  5. 'account/register',
  6. 'account/login',
  7. 'account/logout',
  8. 'account/forgotten',
  9. );
  10.  
  11. // Who can access
  12. $allowed_customer_group_id = array(
  13. 1,
  14. 2,
  15. 3
  16. );
  17.  
  18. $current_customer_group_id = $this->config->get('config_customer_group_id');
  19. if($this->request->get['route']){
  20. $current_page = $this->request->get['route'];
  21. } else {
  22. $current_page = 'common/home';
  23. }
  24.  
  25. // notification
  26. $data['notice'] = '';
  27.  
  28. if(!in_array($current_customer_group_id, $allowed_customer_group_id) || !$this->customer->isLogged()){
  29. if(!in_array($current_page, $allowed_routes)){
  30. // not allowed
  31. // do something, redirect to login page
  32. if($this->customer->isLogged()){
  33. $this->response->redirect($this->url->link('common/home', '', true));
  34. } else {
  35. $this->response->redirect($this->url->link('account/login', '', true));
  36. // or $this->response->redirect($this->url->link('account/register', '', true));
  37. }
  38. } else {
  39. $data['notice'] = 'Some notification message here!';
  40. }
  41. }
  42.  
  43. {% if notice %}
  44. <p class="alert alert-info">{{ notice }}</p>
  45. {% endif %}
Add Comment
Please, Sign In to add comment