accountController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. class accountController extends Staple_AuthController
  3. {
  4. protected $Account;
  5. public function _start()
  6. {
  7. $this->_setLayout("account");
  8. }
  9. public function index()
  10. {
  11. $form = new accountForm();
  12. if($form->wasSubmitted())
  13. {
  14. $form->addData($_POST);
  15. if($form->validate())
  16. {
  17. $pin = $_POST['pin'];
  18. $auth = Staple_Auth::get();
  19. $granted = $auth->doAuth(array('pin'=>$pin));
  20. if($granted === true)
  21. {
  22. header('Location: '.$this->_link(array('index','index')));
  23. }
  24. else
  25. {
  26. $this->view->message = "Invalid PIN";
  27. $this->view->form = $form;
  28. $this->layout->addScriptBlock('
  29. $(document).ready(function()
  30. {
  31. $(\'#errorMessage\').foundation(\'reveal\',\'open\');
  32. });
  33. ');
  34. }
  35. }
  36. else
  37. {
  38. $this->view->form = $form;
  39. }
  40. }
  41. else
  42. {
  43. $this->view->form = $form;
  44. }
  45. }
  46. public function account()
  47. {
  48. echo Staple_Auth::get()->getAuthLevel();
  49. }
  50. public function logout()
  51. {
  52. $auth = Staple_Auth::get();
  53. $auth->clearAuth();
  54. header('Location: '.$this->_link(array('account','index')));
  55. exit(0);
  56. }
  57. }
  58. ?>