...
|
...
|
@@ -19,8 +19,10 @@ class LoginController extends AbstractAction |
|
|
{
|
|
|
$this->setTitle('登录');
|
|
|
|
|
|
$refer = $this->get('refer', SITE_MAIN . '/?go=1');
|
|
|
$this->setCookie('refer', $refer);
|
|
|
$refer = $this->get('refer');
|
|
|
if (!empty($refer)) {
|
|
|
$this->setCookie('refer', $refer);
|
|
|
}
|
|
|
|
|
|
$data = array(
|
|
|
'loginIndex' => true, // 模板中使用JS的标识
|
...
|
...
|
@@ -47,8 +49,10 @@ class LoginController extends AbstractAction |
|
|
{
|
|
|
$this->setTitle('国际账号登录');
|
|
|
|
|
|
$refer = $this->get('refer', SITE_MAIN . '/?go=1');
|
|
|
$this->setCookie('refer', $refer);
|
|
|
$refer = $this->get('refer');
|
|
|
if (!empty($refer)) {
|
|
|
$this->setCookie('refer', $refer);
|
|
|
}
|
|
|
|
|
|
$data = array();
|
|
|
$data['loginInternational'] = true; // 模板中使用JS的标识
|
...
|
...
|
@@ -70,7 +74,9 @@ class LoginController extends AbstractAction |
|
|
{
|
|
|
$this->setCookie('_UID', '');
|
|
|
|
|
|
headers_sent() || header('Location: /');
|
|
|
$refer = $this->server('HTTP_REFERER', SITE_MAIN);
|
|
|
|
|
|
$this->go($refer);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -115,12 +121,11 @@ class LoginController extends AbstractAction |
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
} else {
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
$data['data'] = array(
|
|
|
// 为了异步调用老系统的SESSION会话
|
|
|
'session' => 'http://m1.yohobuy.com/Passport/session/index?callback=call&uid=' . $data['data']['uid'] . '&sign=' . md5($data['data']['uid'] . 'Js8Yn0!EwPM45-ws'),
|
|
|
'href' => rawurldecode($refer),
|
|
|
);
|
|
|
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
|
|
|
$data['data']['href'] = $refer;
|
|
|
} while (false);
|
|
|
|
|
|
$this->echoJson($data);
|
...
|
...
|
@@ -131,10 +136,6 @@ class LoginController extends AbstractAction |
|
|
*/
|
|
|
public function alipayAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('alipay_redirect', $redirect);
|
|
|
}
|
|
|
Factory::create('alipay')->getAuthorizeUrl();
|
|
|
|
|
|
exit();
|
...
|
...
|
@@ -145,10 +146,6 @@ class LoginController extends AbstractAction |
|
|
*/
|
|
|
public function qqAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('qq_redirect', $redirect);
|
|
|
}
|
|
|
Factory::create('qqconnect')->getAuthorizeUrl();
|
|
|
|
|
|
exit();
|
...
|
...
|
@@ -159,13 +156,7 @@ class LoginController extends AbstractAction |
|
|
*/
|
|
|
public function sinaAction()
|
|
|
{
|
|
|
$redirect = $this->_request->getServer('HTTP_REFERER', '');
|
|
|
if ($redirect != '') {
|
|
|
$this->setCookie('sina_redirect', $redirect);
|
|
|
}
|
|
|
header('Location:' . Factory::create('sinaweibo')->getAuthorizeUrl());
|
|
|
|
|
|
exit();
|
|
|
$this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -173,30 +164,27 @@ class LoginController extends AbstractAction |
|
|
*/
|
|
|
public function alipaycallbackAction()
|
|
|
{
|
|
|
$nickname = '';
|
|
|
$alipay = Factory::create('alipay');
|
|
|
$access = $alipay->getAccessToken();
|
|
|
|
|
|
if (!isset($_GET['real_name'])) {
|
|
|
/* 获取支付宝用户的详细信息 */
|
|
|
$userInfo = $alipay->getUserInfo($access);
|
|
|
if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) {
|
|
|
$nickname = $userInfo['response']['user_info']['user_name'];
|
|
|
// $alipayEmail = $userInfo['response']['user_info']['email'];
|
|
|
}
|
|
|
$realName = $this->_request->get('real_name');
|
|
|
$email = $this->_request->get('email');
|
|
|
$userId = $this->_request->get('user_id');
|
|
|
|
|
|
$result = array();
|
|
|
if (isset($realName, $email, $userId)) {
|
|
|
$result = LoginData::signinByOpenID($realName, $userId, 'alipay');
|
|
|
}
|
|
|
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
} else {
|
|
|
$nickname = $_GET['real_name'];
|
|
|
// $alipayEmail = isset($_GET['email']) ? $_GET['email'] : '';
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
$result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq');
|
|
|
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('alipay_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
|
|
|
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
} else {
|
|
|
$this->go($refer);
|
|
|
}
|
|
|
|
|
|
$this->redirect('/');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -209,16 +197,23 @@ class LoginController extends AbstractAction |
|
|
/* 获取QQ腾讯用户的详细信息 */
|
|
|
$partnerInfo = $qqconnect->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
|
|
|
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('qq_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
}
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
|
|
|
}
|
|
|
|
|
|
$this->redirect('/');
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
} else {
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
} else {
|
|
|
$this->go($refer);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -231,16 +226,24 @@ class LoginController extends AbstractAction |
|
|
/* 获取QQ腾讯用户的详细信息 */
|
|
|
$partnerInfo = $sina->getUserInfo($access);
|
|
|
|
|
|
$result = array();
|
|
|
|
|
|
if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
|
|
|
|
|
|
if ($result['code'] == 200) {
|
|
|
$redirect = $this->_request->getCookie('sina_redirect');
|
|
|
$redirect && $this->redirect($redirect);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->redirect('/');
|
|
|
$refer = $this->getCookie('refer');
|
|
|
if (empty($refer)) {
|
|
|
$refer = SITE_MAIN . '/?go=1';
|
|
|
} else {
|
|
|
$refer = rawurldecode($refer);
|
|
|
}
|
|
|
|
|
|
if ($result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
} else {
|
|
|
$this->go($refer);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|