Advertisement
dragonbe

Zend_Auth and Zend_Db

May 2nd, 2011
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. APPLICATION_PATH . '/application/config/application.ini
  5.  
  6. resources.db.adapter = "Pdo_SQLite"
  7. resources.db.params.dbname = APPLICATION_PATH "/data/db/zftraining.db"
  8. resources.db.isDefaultTableAdapter = true
  9.  
  10. **/
  11.  
  12.  
  13. public function authAction()
  14. {
  15.     // I love Zend Framework - MyPassword01
  16.     $salt = 'I love Zend Framework';
  17.     $email = $this->getRequest()->getParam('email');
  18.     $password = md5($salt . ' - ' . $this->getRequest()->getParam('password'));
  19.    
  20.     $bootstrap = $this->getInvokeArg('bootstrap');
  21.     $db = $bootstrap->getResource('db');
  22.     if ($db instanceof Zend_Db_Adapter_Abstract) {
  23.         $db->getProfiler()->setEnabled(true);
  24.     }
  25.    
  26.     $auth = new Zend_Auth_Adapter_DbTable($db);
  27.     $auth->setTableName('member')
  28.          ->setIdentityColumn('email')
  29.          ->setCredentialColumn('password')
  30.          ->setIdentity($email)
  31.          ->setCredential($password);
  32.          
  33.     try {
  34.     $result = $auth->authenticate();
  35.     } catch (Zend_Auth_Exception $e) {
  36.         echo $e->getMessage();
  37.     }
  38.     $this->view->messages = $result->getMessages();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement