ライブ サイトで 1 つのアクションを別のアクションにリダイレクトすることに関連する問題があります。
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');
}
}
Zend Framework-2 でサイトを作成し、Linux サーバーにデプロイしましたが、リダイレクト時に機能しないはずです。前のアクションで停止します。例:- 認証時には正常に認証できますが、リダイレクト時に停止します。$this->redirect()->toRoute('admin'); このコードは機能せず、プロジェクト全体でリダイレクトが機能していません。toRoute('admin') または toUrl(' http://marwarishaadicentre.in/admin ') これらの関数は機能しません。