123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- class accountController extends Staple_AuthController
- {
- protected $Account;
-
- public function _start()
- {
- $this->_setLayout("account");
- $this->_openMethod('admin');
- }
-
- public function index()
- {
- $form = new adminAccountForm();
- if($form->wasSubmitted())
- {
- $form->addData($_POST);
- if($form->validate())
- {
- $password = $_POST['password'];
- $account = $_POST['username'];
- $auth = Staple_Auth::get();
- $granted = $auth->doAuth(array('username'=>$account,'password'=>$password));
- if($granted === true)
- {
- header('Location: '.$this->_link(array('index','index')));
- }
- else
- {
- $this->view->message = "Invalid login";
- $this->view->form = $form;
- }
- }
- else
- {
- $this->view->form = $form;
- }
- }
- else
- {
- $this->view->form = $form;
- }
- /*
- $form = new accountForm();
- if($form->wasSubmitted())
- {
- $form->addData($_POST);
- if($form->validate())
- {
- $pin = $_POST['pin'];
- $auth = Staple_Auth::get();
- $granted = $auth->doAuth(array('pin'=>$pin));
- if($granted === true)
- {
- header('Location: '.$this->_link(array('index','index')));
- }
- else
- {
- $this->view->message = "Invalid PIN";
- $this->view->form = $form;
- $this->layout->addScriptBlock('
- $(document).ready(function()
- {
- $(\'#errorMessage\').foundation(\'reveal\',\'open\');
- });
- ');
- }
- }
- else
- {
- $this->view->form = $form;
- }
- }
- else
- {
- $this->view->form = $form;
- }
- */
- }
- public function account()
- {
- echo Staple_Auth::get()->getAuthLevel();
- }
- public function admin()
- {
- $form = new adminAccountForm();
- if($form->wasSubmitted())
- {
- $form->addData($_POST);
- if($form->validate())
- {
- $password = $_POST['password'];
- $account = $_POST['username'];
- $auth = Staple_Auth::get();
- $granted = $auth->doAuth(array('username'=>$account,'password'=>$password));
- if($granted === true)
- {
- header('Location: '.$this->_link(array('timesheet','index')));
- }
- else
- {
- $this->view->message = "Invalid login";
- $this->view->form = $form;
- }
- }
- else
- {
- $this->view->form = $form;
- }
- }
- else
- {
- $this->view->form = $form;
- }
- }
- public function logout()
- {
- $auth = Staple_Auth::get();
- $auth->clearAuth();
- header('Location: '.$this->_link(array('account','index')));
- exit(0);
- }
- }
- ?>
|