...
|
...
|
@@ -2,7 +2,6 @@ |
|
|
|
|
|
use Action\AbstractAction;
|
|
|
use LibModels\Web\Passport\LoginData;
|
|
|
use Passport\PassportModel as PassportModel;
|
|
|
use Plugin\Helpers;
|
|
|
use Plugin\Partner\Factory;
|
|
|
|
...
|
...
|
@@ -62,13 +61,14 @@ class AutosignController extends AbstractAction |
|
|
|
|
|
$this->go(Factory::create('douban')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
/**
|
|
|
* 微信网站授权入口
|
|
|
*/
|
|
|
public function wechatAction(){
|
|
|
$url = QINWechat_Sdk_Open::getCode('http://www.yohobuy.com/passport/autosign/wechatback');
|
|
|
$this->helpGo($url);
|
|
|
public function wechatAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
$this->go(Factory::create('wechat')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -88,7 +88,12 @@ class AutosignController extends AbstractAction |
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
...
|
...
|
@@ -126,11 +131,6 @@ class AutosignController extends AbstractAction |
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
$this->go(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
...
|
...
|
@@ -139,6 +139,16 @@ class AutosignController extends AbstractAction |
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
...
|
...
|
@@ -169,7 +179,12 @@ class AutosignController extends AbstractAction |
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
...
|
...
|
@@ -199,18 +214,21 @@ class AutosignController extends AbstractAction |
|
|
{
|
|
|
$renren = Factory::create('renren');
|
|
|
$access = $renren->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $renren->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
if ($access && is_array($access)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
|
|
|
$result = LoginData::signinByOpenID($access['user']['name'], $access['user']['id'], 'renren', $shoppingKey);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['user']['id'], 'sourceType' => 'renren', 'nickname' => $access['user']['name'])));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
...
|
...
|
@@ -238,20 +256,25 @@ class AutosignController extends AbstractAction |
|
|
*/
|
|
|
public function doubanbackAction()
|
|
|
{
|
|
|
$sina = Factory::create('douban');
|
|
|
$access = $sina->getAccessToken();
|
|
|
$douban = Factory::create('douban');
|
|
|
$access = $douban->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $sina->getUserInfo($access);
|
|
|
$partnerInfo = $douban->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['name'], $partnerInfo['uid'], 'douban', $shoppingKey);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['douban_user_id'], 'sourceType' => 'douban', 'nickname' => $partnerInfo['name'])));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
...
|
...
|
@@ -273,52 +296,51 @@ class AutosignController extends AbstractAction |
|
|
$this->go($refer);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 微信网站授权获取用户信息并登录
|
|
|
* @param string code
|
|
|
*/
|
|
|
public function wechatbackAction(){
|
|
|
$code = $this->helpGquery('code');
|
|
|
$accessToken = QINWechat_Sdk_Open::getAccessToken($code);
|
|
|
$userInfo = array();
|
|
|
if(empty($accessToken)){
|
|
|
$this->helpGo('/signin.html');
|
|
|
}
|
|
|
if(!isset($accessToken['access_token']) || !isset($accessToken['unionid']) || empty($accessToken['access_token']) || empty($accessToken['unionid'])){
|
|
|
$this->helpGo('/signin.html');
|
|
|
}
|
|
|
$userInfo = QINWechat_Sdk_Open::getUserInfo($accessToken['access_token'], $accessToken['unionid']);
|
|
|
if(empty($userInfo)){
|
|
|
$this->helpGo('/signin.html');
|
|
|
}
|
|
|
$this->wechatlogin($userInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信登录
|
|
|
* @param array $userInfo
|
|
|
*/
|
|
|
public function wechatlogin($userInfo){
|
|
|
if(empty($userInfo)){
|
|
|
$this->helpGo('/signin.html');
|
|
|
}
|
|
|
try {
|
|
|
$oauthUserInfo = QINAuth_User_Utils::check('wechat', $userInfo['unionid'], $userInfo['nickname'], null, $userInfo);
|
|
|
$auth = QINAuth_Factory::profile('wechat');
|
|
|
$res=$auth->associate($oauthUserInfo['email'], array(
|
|
|
'password' => QINAuth_User_Utils::$defaultPassword,
|
|
|
'open_id' => $userInfo['unionid'],
|
|
|
'nick_name' => $userInfo['nickname']
|
|
|
));
|
|
|
} catch (Exception $e) {
|
|
|
$this->helpSession('passport_space')->__set('error_message', 'wechat' . $e->getMessage());
|
|
|
$this->helpGo('/signin.html');
|
|
|
}
|
|
|
//跳转到
|
|
|
$url = $this->authInfo($res, 'wechat' , $oauthUserInfo['email']);
|
|
|
$this->helpGo($url);
|
|
|
}
|
|
|
public function wechatbackAction()
|
|
|
{
|
|
|
$wechat = Factory::create('wechat');
|
|
|
$access = $wechat->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $wechat->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'],$partnerInfo['openid'], 'wechat', $shoppingKey,$partnerInfo['openid']);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $partnerInfo['openid'], 'sourceType' => 'wechat', 'nickname' => $partnerInfo['nickname'])));
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
}
|
|
|
else {
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
$token = Helpers::makeToken($result['data']['uid']);
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
}
|
|
|
else {
|
|
|
$this->go($refer);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|