3
我爲我的應用使用了Zend Framework 2.2.4,我爲登錄頁面添加了「用Google登錄」選項。但它沒有在確切的頁面上重定向,它返回到登錄頁面並且放置#重定向到路由在Zend Framework中不工作
例如, myapp.dev/login#
這是「登錄在與谷歌」的方法,這是位於我LoggingController.php
public function loginSocialsAction()
{
$googleClient = $this->getGoogleClient();
$code = $this->params()->fromQuery('code', '');
$googleOauthV2 = new \Google_Oauth2Service($googleClient);
#if successful validation from Google
if (isset($code)) {
$googleClient->authenticate($code);
$gdata = $googleOauthV2->userinfo->get();
$user = $this->getUsersTable()->getByEmail($gdata['email']);
}
if ($googleClient->getAccessToken() && isset($gdata['email'])) {
if (!empty($user)) {
$user->role = $this->getRoleTable()->get($user->roleId);
$session = new Session\Container('currentuser');
$session->user = $user;
$this->initializeSession($session);
// if success, go to records page
return $this->redirect()->toRoute('records');
} else {
$message = 'The user is not in the system.';
$this->flashMessenger()->setNamespace('error')->addErrorMessage($message);
return $this->redirect()->toRoute('login');
}
} else {
$message = 'Google auth failed.';
$this->flashMessenger()->setNamespace('error')->addErrorMessage($message);
return $this->redirect()->toRoute('login');
}
}
請註明,我錯過了的東西或者你想知道。任何想法(s)真的會有幫助!
請提供您的路線('登錄'和'記錄'),錯誤可以在那裏。 –