...
|
...
|
@@ -26,7 +26,7 @@ class LoginController extends AbstractAction |
|
|
$this->setCookie('_TOKEN', '');
|
|
|
|
|
|
//登录后跳转页面
|
|
|
$refer = $this->get('refer');
|
|
|
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
|
|
|
if (!empty($refer)) {
|
|
|
$this->setCookie('refer', $refer);
|
|
|
}
|
...
|
...
|
@@ -55,17 +55,17 @@ class LoginController extends AbstractAction |
|
|
'simpleHeader' => $simpleHeader,
|
|
|
'passport' => array(
|
|
|
'coverHref' => $coverHref,
|
|
|
'coverImg' => $coverImg,
|
|
|
'coverImg' => !empty($coverImg)?$coverImg:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
|
|
|
'countryCode' => '+86',
|
|
|
'countryName' => '中国',
|
|
|
'countryList' => RegData::getAreasData(),
|
|
|
'forgetPwd' => Helpers::url('/passport/back/index'),
|
|
|
'fastReg' => Helpers::url('/reg.html'),
|
|
|
'qqLogin' => Helpers::url('/passport/login/qq'),
|
|
|
'weiboLogin' => Helpers::url('/passport/login/sina'),
|
|
|
'alipayLogin' => Helpers::url('/passport/login/alipay'),
|
|
|
'doubanLogin' => Helpers::url('/passport/login/douban'),
|
|
|
'renrenLogin' => Helpers::url('/passport/login/renren'),
|
|
|
'qqLogin' => Helpers::url('/passport/autosign/qq'),
|
|
|
'weiboLogin' => Helpers::url('/passport/autosign/sina'),
|
|
|
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
|
|
|
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
|
|
|
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
|
|
|
),
|
|
|
);
|
|
|
|
...
|
...
|
@@ -160,262 +160,4 @@ class LoginController extends AbstractAction |
|
|
$this->go($refer);
|
|
|
}
|
|
|
|
|
|
//第三方登录
|
|
|
/**
|
|
|
* 支付宝登录:授权页面
|
|
|
*/
|
|
|
public function alipayAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
|
|
|
Factory::create('alipay')->getAuthorizeUrl();
|
|
|
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* QQ账号登录:授权页面
|
|
|
*/
|
|
|
public function qqAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
|
|
|
Factory::create('qqconnect')->getAuthorizeUrl();
|
|
|
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新浪微博账号登录:授权页面
|
|
|
*/
|
|
|
public function sinaAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
|
|
|
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新浪微博账号登录:授权页面
|
|
|
*/
|
|
|
public function renrenAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
|
|
|
$this->go(Factory::create('renren')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 豆瓣账号登录:授权页面
|
|
|
*/
|
|
|
public function doubanAction()
|
|
|
{
|
|
|
$this->setSession('_TOKEN', '');
|
|
|
|
|
|
$this->go(Factory::create('douban')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 支付宝账号登录:回调方法
|
|
|
*/
|
|
|
public function alipaycallbackAction()
|
|
|
{
|
|
|
$realName = $this->_request->get('real_name');
|
|
|
$email = $this->_request->get('email');
|
|
|
$userId = $this->_request->get('user_id');
|
|
|
|
|
|
$result = array();
|
|
|
if (isset($realName, $email, $userId)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($realName, $userId, 'alipay', $shoppingKey);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* QQ账号登录:回调方法
|
|
|
*/
|
|
|
public function qqcallbackAction()
|
|
|
{
|
|
|
$qqconnect = Factory::create('qqconnect');
|
|
|
$access = $qqconnect->getAccessToken();
|
|
|
/* 获取QQ腾讯用户的详细信息 */
|
|
|
$partnerInfo = $qqconnect->getUserInfo($access);
|
|
|
$result = array();
|
|
|
if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
|
|
|
}
|
|
|
|
|
|
//判定是否需要绑定手机号
|
|
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新浪微博账号登录:回调方法
|
|
|
*/
|
|
|
public function sinacallbackAction()
|
|
|
{
|
|
|
$sina = Factory::create('sinaweibo');
|
|
|
$access = $sina->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $sina->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina', $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'])));
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* renren账号登录:回调方法
|
|
|
*/
|
|
|
public function renrenbackAction()
|
|
|
{
|
|
|
$renren = Factory::create('renren');
|
|
|
$access = $renren->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $renren->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], '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'])));
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* douban账号登录:回调方法
|
|
|
*/
|
|
|
public function doubanbackAction()
|
|
|
{
|
|
|
$sina = Factory::create('douban');
|
|
|
$access = $sina->getAccessToken();
|
|
|
/* 获取用户的详细信息 */
|
|
|
$partnerInfo = $sina->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['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'])));
|
|
|
}
|
|
|
|
|
|
$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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|