Browse Source

Moved the admin login to the index method in the accounts controller or the demo site.

Adam Day 9 years ago
parent
commit
b6258f6af1
1 changed files with 35 additions and 0 deletions
  1. 35 0
      application/controllers/accountController.php

+ 35 - 0
application/controllers/accountController.php

@@ -11,6 +11,40 @@ class accountController extends Staple_AuthController
 	
 	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('timesheet','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())
 		{
@@ -47,6 +81,7 @@ class accountController extends Staple_AuthController
 		{
 			$this->view->form = $form;
 		}
+		*/
 	}
 
 	public function account()