I have a problem related to redirecting one action to another on live site.(http://marwarishaadicentre.in/) I post the Auth Controller code in this code in Authenticate Action can authenticate successfully but not redirect on admin or profile route.
public function authenticateAction()
{
$user_session = new Container('user');
$form = $this->getForm();
$redirect = 'member/login';
$request = $this->getRequest();
if($request->isPost())
{
$form ->setData($request->getPost());
if($form->isValid())
{
$username = $request->getPost('username');
$password = $request->getPost('password');
$credential = $this->getAuthService()->getAdapter()
->setIdentity($request->getPost('username'))
->setCredential($request->getPost('password'));
$is_active = $this->getUserTable()->checkActivation($username,$password);
$is_admin = $this->getUserTable()->checkAdmin($username);
$is_verify = $this->getUserTable()->checkVerify($username);
$user_session = new \Zend\Session\Container('user');
$user_session->is_admin=$is_admin->is_admin;
foreach($is_active as $row)
{
$a = $row->is_active;
}
$credential->getDbSelect()->where('is_active = TRUE');
$result = $this->getAuthService()->authenticate();
switch ($result->getCode()) {
case Result::FAILURE_IDENTITY_NOT_FOUND:
/** do stuff for nonexistent identity **/
if($a == 0)
{
$this->flashMessenger()->addMessage('Your account could not be verified!
Or Wrong Username was entered');
}
else
{
$this->flashMessenger()->addMessage('Please check your username !!!');
}
break;
case Result::FAILURE_CREDENTIAL_INVALID:
/** do stuff for invalid credential **/
$this->flashMessenger()->addMessage('Wrong Password entered!!!');
break;
case Result::SUCCESS:
/** do stuff for successful authentication **/
$user_session->username = $request->getPost('username');
$redirect_admin = 'admin';
$redirect_mem='profile';
if($request -> getPost('rememberme') == 1)
{
$this->getSessionStorage() ->setRememberMe(1);
$this ->getAuthService() -> setStorage($this -> getSessionStorage());
}
$this->getAuthService()->setStorage($this->getSessionStorage());
$this->getAuthService()->getStorage()->write($request->getPost('username'));
break;
case Result::FAILURE_UNCATEGORIZED:
$this->flashMessenger()->addMessage('Uncategorized Failure occurred. Please try again later!!!');
break;
default:
/** do stuff for other failure **/
$this->flashMessenger()->addMessage('Something unexpected went. Please try again later!!!');
break;
}
}
}
if($is_admin->is_admin=='Y')
{
return $this -> redirect() -> toRoute($redirect_admin);
}
if($a==NULL)
{
$this->flashMessenger()->addMessage('Your account could not be verified!
Or Wrong Username was entered');
}
if($is_verify->is_verify==0)
{
return $this -> redirect()->toUrl('http://marwarishaadicentre.in/profile/edit/'.$is_verify->mem_code);
}
else
{
return $this -> redirect() -> toRoute('profile');
}
}
I create my site in zend framework-2 and deployed on Linux Server but at the time of redirecting it should not work. It will stop on previous action. ex:- At the time of authentication it can authenticate successfully but on redirect it will stop. $this->redirect()->toRoute('admin'); this code is not work and in whole project any where redirect is not working. toRoute('admin') or toUrl('http://marwarishaadicentre.in/admin') these functions are not work.