添加了登录页面自动登录科技网通行证的代码
This commit is contained in:
parent
35ac496667
commit
bc49f03f75
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
use Mail\Mail;
|
||||
use Open\Client;
|
||||
use Open\OAuth2;
|
||||
use Users\Account;
|
||||
use Users\Member;
|
||||
use Helpers\Captcha;
|
||||
|
@ -306,6 +307,15 @@ class AccountController extends Zend_Controller_Action
|
|||
$this->view->href = $tohref;
|
||||
}
|
||||
|
||||
$oauth2 = new OAuth2();
|
||||
if($oauth2->loginTest())
|
||||
{
|
||||
$client = new Client();
|
||||
$url = $client->makeRequestCodeUrl("escience");
|
||||
|
||||
view::Post($this,"为您转入科技网登录入口",$url);
|
||||
}
|
||||
|
||||
$captcha = new Captcha();
|
||||
|
||||
$submit = $this->_getParam("submit");
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
namespace Open;
|
||||
|
||||
use Open\Client;
|
||||
use Helpers\Curl;
|
||||
use Helpers\Table;
|
||||
|
||||
class OAuth2 extends \Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public $db;
|
||||
|
@ -23,9 +27,28 @@ class OAuth2 extends \Zend_Controller_Plugin_Abstract
|
|||
|
||||
}
|
||||
|
||||
//用户使用谷歌账号登陆
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue