$request = $this->getRequest();
if ($request->isPost()) {
$params = $this->filterInput($request->getParams());
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'mdl_registration_user');
$authAdapter->setIdentityColumn('uname')
->setCredentialColumn('password');
$authAdapter->setIdentity($params['uname'])
->setCredential(md5($params['password']));
// extra validation
$authAdapter->getDbSelect()->where('countrycode = +'.$params['country']);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$user = $authAdapter->getResultRowObject();
$auth->getStorage()->write($user);
$flash_obj->addMessage('You have loged-in successfully');
$this->_redirect('index/index');
} else {
$this->view->messages = "Invalid username or password. Please try again.";
return ;
}
}
Comments
Post a Comment