添加了登录页面自动登录科技网通行证的代码

This commit is contained in:
Li Jianxuan 2014-10-23 09:42:49 +00:00
parent 35ac496667
commit bc49f03f75
2 changed files with 40 additions and 7 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
use Mail\Mail; use Mail\Mail;
use Open\Client; use Open\Client;
use Open\OAuth2;
use Users\Account; use Users\Account;
use Users\Member; use Users\Member;
use Helpers\Captcha; use Helpers\Captcha;
@ -278,7 +279,7 @@ class AccountController extends Zend_Controller_Action
} }
function loginAction() function loginAction()
{ {
$options = array( $options = array(
'module' => $this->_request->getModuleName(), 'module' => $this->_request->getModuleName(),
'controller' => $this->_request->getControllerName(), 'controller' => $this->_request->getControllerName(),
@ -305,6 +306,15 @@ class AccountController extends Zend_Controller_Action
{ {
$this->view->href = $tohref; $this->view->href = $tohref;
} }
$oauth2 = new OAuth2();
if($oauth2->loginTest())
{
$client = new Client();
$url = $client->makeRequestCodeUrl("escience");
view::Post($this,"为您转入科技网登录入口",$url);
}
$captcha = new Captcha(); $captcha = new Captcha();

View File

@ -1,6 +1,10 @@
<?php <?php
namespace Open; namespace Open;
use Open\Client;
use Helpers\Curl;
use Helpers\Table;
class OAuth2 extends \Zend_Controller_Plugin_Abstract class OAuth2 extends \Zend_Controller_Plugin_Abstract
{ {
public $db; public $db;
@ -22,10 +26,29 @@ class OAuth2 extends \Zend_Controller_Plugin_Abstract
$this->table = new Table(); $this->table = new Table();
} }
//用户使用谷歌账号登陆 //登录测试
public function googleClient() public function loginTest()
{ {
try {
} $client = new Client();
$url = $client->makeRequestCodeUrl("escience");
$curl = new Curl();
$curl->port = 443;
$curl->initOptions(array('verifyssl' => false));
$data = $curl->request($url, array(), "POST");
$cache_data = $data;
if (isset($data['headers']['http_code']) && $data['headers']['http_code'] == 302) {
return true;
} else {
return false;
}
}catch (\Exception $e)
{
return false;
}
}
} }