Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AuthController extends Zend_Controller_Action
- {
- public function init()
- {
- $db = Zend_Db::factory('Pdo_Mysql', array(
- 'host' => 'localhost',
- 'username' => 'test',
- 'password' => 'test',
- 'dbname' => 'test',
- ));
- Zend_Db_Table::setDefaultAdapter($db);
- }
- public function indexAction()
- {
- // action body
- }
- public function loginAction()
- {
- $config = $this->getInvokeArg('bootstrap')->getOption('auth');
- $salt = $config['salt'];
- $auth = new Zend_Auth_Adapter_DbTable(
- Zend_Db_Table::getDefaultAdapter(),
- 'users',
- 'email',
- 'password',
- 'SHA1(?)'
- );
- $auth->setIdentity($this->getRequest()->getPost('email'))
- ->setCredential($this->getRequest()->getPost('password') . $salt);
- $result = $auth->authenticate();
- echo $result->isValid();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement