Advertisement
Guest User

My auth Controller

a guest
May 2nd, 2011
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2.  
  3. class AuthController extends Website_Controller_Action{
  4.  
  5. public function indexAction() {
  6. Zend_Loader::loadClass('Application_Form_Login');
  7.  
  8.  
  9. $form = new Application_Form_Login();
  10. $request = $this->getRequest();
  11. if ($request->isPost()) {
  12. echo "Posted";
  13. if ($form->isValid($request->getPost())) {
  14. if ($this->_process($form->getValues())) {
  15. die('WE DID IT BABY!');
  16. // We're authenticated! Redirect to the home age
  17. $this->_helper->redirector('index', 'index');
  18. }
  19. else
  20. {
  21. echo "Yall niggas ain't SHEET";
  22. }
  23. }
  24. }
  25. $this->view->form = $form;
  26. $this->enableLayout();
  27. $this->setLayout('auth/index');
  28. }
  29.  
  30. protected function _process($values){
  31. $adapter = $this->_getAuthAdapter();
  32. $adapter->setIdentity($values['username']);
  33. $adapter->setCredential($values['password']);
  34.  
  35. $auth = Zend_Auth::getInstance();
  36. $result = $auth->authenticate($adapter);
  37. if ($result->isValid()) {
  38. $user = $result->getIdentity();
  39. $auth->getStorage()->write($user);
  40. return true;
  41. }
  42. return false;
  43. }
  44.  
  45. protected function _getAuthAdapter() {
  46. $authAdapter = new Website_Auth_ObjectAdapter('Object_Users', 'o_key', 'password', '/users/');
  47. return $authAdapter;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement