Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AuthController extends Website_Controller_Action{
- public function indexAction() {
- Zend_Loader::loadClass('Application_Form_Login');
- $form = new Application_Form_Login();
- $request = $this->getRequest();
- if ($request->isPost()) {
- echo "Posted";
- if ($form->isValid($request->getPost())) {
- if ($this->_process($form->getValues())) {
- die('WE DID IT BABY!');
- // We're authenticated! Redirect to the home age
- $this->_helper->redirector('index', 'index');
- }
- else
- {
- echo "Yall niggas ain't SHEET";
- }
- }
- }
- $this->view->form = $form;
- $this->enableLayout();
- $this->setLayout('auth/index');
- }
- protected function _process($values){
- $adapter = $this->_getAuthAdapter();
- $adapter->setIdentity($values['username']);
- $adapter->setCredential($values['password']);
- $auth = Zend_Auth::getInstance();
- $result = $auth->authenticate($adapter);
- if ($result->isValid()) {
- $user = $result->getIdentity();
- $auth->getStorage()->write($user);
- return true;
- }
- return false;
- }
- protected function _getAuthAdapter() {
- $authAdapter = new Website_Auth_ObjectAdapter('Object_Users', 'o_key', 'password', '/users/');
- return $authAdapter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement