Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AuthenticationController extends Zend_Controller_Action
- {
- public function init()
- {
- /* Initialize action controller here */
- }
- public function indexAction()
- {
- // action body
- }
- public function loginAction()
- {
- $form = new getLoginForm();
- $this->view->form = $form;
- $authAdapter = $this->getAuthAdapter();
- $username = 'Lala';
- $password = '912ec803b2ce49e4a541068d495ab570';
- $authAdapter->setIdentity($username)
- ->setCredential($password);
- $auth = Zend_Auth::getInstance();
- $result = $auth->authenticate($authAdapter);
- if($result -> isValid()){
- $identity = $authAdapter->getResultRowObject();
- $authStorage = $auth->getStorage();
- $authStorage->write($identity);
- $this->_redirect('index/index');
- }else{
- echo 'Invalid';
- }
- return $result;
- }
- public function logoutAction()
- {
- // action body
- }
- private function getAuthAdapter(){
- $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
- $authAdapter->setTableName('users')
- ->setIdentityColumn('username')
- ->setCredentialColumn('password');
- return $authAdapter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement