فهرست منبع

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

Adam Day 10 سال پیش
والد
کامیت
b6258f6af1
1فایلهای تغییر یافته به همراه35 افزوده شده و 0 حذف شده
  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()