|
@@ -2,7 +2,6 @@ |
|
@@ -2,7 +2,6 @@ |
2
|
|
2
|
|
3
|
use Action\AbstractAction;
|
3
|
use Action\AbstractAction;
|
4
|
use LibModels\Web\Passport\LoginData;
|
4
|
use LibModels\Web\Passport\LoginData;
|
5
|
-use Passport\PassportModel as PassportModel;
|
|
|
6
|
use Plugin\Helpers;
|
5
|
use Plugin\Helpers;
|
7
|
use Plugin\Partner\Factory;
|
6
|
use Plugin\Partner\Factory;
|
8
|
|
7
|
|
|
@@ -66,9 +65,10 @@ class AutosignController extends AbstractAction |
|
@@ -66,9 +65,10 @@ class AutosignController extends AbstractAction |
66
|
/**
|
65
|
/**
|
67
|
* 微信网站授权入口
|
66
|
* 微信网站授权入口
|
68
|
*/
|
67
|
*/
|
69
|
- public function wechatAction(){
|
|
|
70
|
- $url = QINWechat_Sdk_Open::getCode('http://www.yohobuy.com/passport/autosign/wechatback');
|
|
|
71
|
- $this->helpGo($url);
|
68
|
+ public function wechatAction()
|
|
|
69
|
+ {
|
|
|
70
|
+ $this->setSession('_TOKEN', '');
|
|
|
71
|
+ $this->go(Factory::create('wechat')->getAuthorizeUrl());
|
72
|
}
|
72
|
}
|
73
|
|
73
|
|
74
|
/**
|
74
|
/**
|
|
@@ -88,7 +88,12 @@ class AutosignController extends AbstractAction |
|
@@ -88,7 +88,12 @@ class AutosignController extends AbstractAction |
88
|
|
88
|
|
89
|
//判定是否需要绑定手机号
|
89
|
//判定是否需要绑定手机号
|
90
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
90
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
91
|
- $this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
|
91
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
92
|
+ $this->setSession('_TOKEN', $token);
|
|
|
93
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
94
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
95
|
+ $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
|
|
|
96
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
92
|
}
|
97
|
}
|
93
|
|
98
|
|
94
|
$refer = $this->getCookie('refer');
|
99
|
$refer = $this->getCookie('refer');
|
|
@@ -126,11 +131,6 @@ class AutosignController extends AbstractAction |
|
@@ -126,11 +131,6 @@ class AutosignController extends AbstractAction |
126
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
|
131
|
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
|
127
|
}
|
132
|
}
|
128
|
|
133
|
|
129
|
- //判定是否需要绑定手机号
|
|
|
130
|
- if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
131
|
- $this->go(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
|
|
|
132
|
- }
|
|
|
133
|
-
|
|
|
134
|
$refer = $this->getCookie('refer');
|
134
|
$refer = $this->getCookie('refer');
|
135
|
if (empty($refer)) {
|
135
|
if (empty($refer)) {
|
136
|
$refer = SITE_MAIN . '/?go=1';
|
136
|
$refer = SITE_MAIN . '/?go=1';
|
|
@@ -139,6 +139,16 @@ class AutosignController extends AbstractAction |
|
@@ -139,6 +139,16 @@ class AutosignController extends AbstractAction |
139
|
$refer = rawurldecode($refer);
|
139
|
$refer = rawurldecode($refer);
|
140
|
}
|
140
|
}
|
141
|
|
141
|
|
|
|
142
|
+ //判定是否需要绑定手机号
|
|
|
143
|
+ if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
144
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
145
|
+ $this->setSession('_TOKEN', $token);
|
|
|
146
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
147
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
148
|
+ $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
|
|
|
149
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
|
|
150
|
+ }
|
|
|
151
|
+
|
142
|
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
152
|
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
143
|
$token = Helpers::makeToken($result['data']['uid']);
|
153
|
$token = Helpers::makeToken($result['data']['uid']);
|
144
|
$this->setSession('_TOKEN', $token);
|
154
|
$this->setSession('_TOKEN', $token);
|
|
@@ -169,7 +179,12 @@ class AutosignController extends AbstractAction |
|
@@ -169,7 +179,12 @@ class AutosignController extends AbstractAction |
169
|
|
179
|
|
170
|
//判定是否需要绑定手机号
|
180
|
//判定是否需要绑定手机号
|
171
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
181
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
172
|
-// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
182
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
183
|
+ $this->setSession('_TOKEN', $token);
|
|
|
184
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
185
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
186
|
+ $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
|
|
187
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
173
|
}
|
188
|
}
|
174
|
|
189
|
|
175
|
$refer = $this->getCookie('refer');
|
190
|
$refer = $this->getCookie('refer');
|
|
@@ -199,18 +214,21 @@ class AutosignController extends AbstractAction |
|
@@ -199,18 +214,21 @@ class AutosignController extends AbstractAction |
199
|
{
|
214
|
{
|
200
|
$renren = Factory::create('renren');
|
215
|
$renren = Factory::create('renren');
|
201
|
$access = $renren->getAccessToken();
|
216
|
$access = $renren->getAccessToken();
|
202
|
- /* 获取用户的详细信息 */
|
|
|
203
|
- $partnerInfo = $renren->getUserInfo($access);
|
|
|
204
|
|
217
|
|
205
|
$result = array();
|
218
|
$result = array();
|
206
|
- if ($partnerInfo && is_array($partnerInfo)) {
|
219
|
+ if ($access && is_array($access)) {
|
207
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
220
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
208
|
- $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
|
221
|
+ $result = LoginData::signinByOpenID($access['user']['name'], $access['user']['id'], 'renren', $shoppingKey);
|
209
|
}
|
222
|
}
|
210
|
|
223
|
|
211
|
//判定是否需要绑定手机号
|
224
|
//判定是否需要绑定手机号
|
212
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
225
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
213
|
-// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
|
226
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
227
|
+ $this->setSession('_TOKEN', $token);
|
|
|
228
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
229
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
230
|
+ $fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['user']['id'], 'sourceType' => 'renren', 'nickname' => $access['user']['name'])));
|
|
|
231
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
214
|
}
|
232
|
}
|
215
|
|
233
|
|
216
|
$refer = $this->getCookie('refer');
|
234
|
$refer = $this->getCookie('refer');
|
|
@@ -238,20 +256,25 @@ class AutosignController extends AbstractAction |
|
@@ -238,20 +256,25 @@ class AutosignController extends AbstractAction |
238
|
*/
|
256
|
*/
|
239
|
public function doubanbackAction()
|
257
|
public function doubanbackAction()
|
240
|
{
|
258
|
{
|
241
|
- $sina = Factory::create('douban');
|
|
|
242
|
- $access = $sina->getAccessToken();
|
259
|
+ $douban = Factory::create('douban');
|
|
|
260
|
+ $access = $douban->getAccessToken();
|
243
|
/* 获取用户的详细信息 */
|
261
|
/* 获取用户的详细信息 */
|
244
|
- $partnerInfo = $sina->getUserInfo($access);
|
262
|
+ $partnerInfo = $douban->getUserInfo($access);
|
245
|
|
263
|
|
246
|
$result = array();
|
264
|
$result = array();
|
247
|
if ($partnerInfo && is_array($partnerInfo)) {
|
265
|
if ($partnerInfo && is_array($partnerInfo)) {
|
248
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
266
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
249
|
- $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
|
267
|
+ $result = LoginData::signinByOpenID($partnerInfo['name'], $partnerInfo['uid'], 'douban', $shoppingKey);
|
250
|
}
|
268
|
}
|
251
|
|
269
|
|
252
|
//判定是否需要绑定手机号
|
270
|
//判定是否需要绑定手机号
|
253
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
271
|
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
254
|
-// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
|
272
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
273
|
+ $this->setSession('_TOKEN', $token);
|
|
|
274
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
275
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
276
|
+ $fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['douban_user_id'], 'sourceType' => 'douban', 'nickname' => $partnerInfo['name'])));
|
|
|
277
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
255
|
}
|
278
|
}
|
256
|
|
279
|
|
257
|
$refer = $this->getCookie('refer');
|
280
|
$refer = $this->getCookie('refer');
|
|
@@ -274,51 +297,50 @@ class AutosignController extends AbstractAction |
|
@@ -274,51 +297,50 @@ class AutosignController extends AbstractAction |
274
|
}
|
297
|
}
|
275
|
}
|
298
|
}
|
276
|
|
299
|
|
277
|
-
|
|
|
278
|
/**
|
300
|
/**
|
279
|
* 微信网站授权获取用户信息并登录
|
301
|
* 微信网站授权获取用户信息并登录
|
280
|
* @param string code
|
302
|
* @param string code
|
281
|
*/
|
303
|
*/
|
282
|
- public function wechatbackAction(){
|
|
|
283
|
- $code = $this->helpGquery('code');
|
|
|
284
|
- $accessToken = QINWechat_Sdk_Open::getAccessToken($code);
|
|
|
285
|
- $userInfo = array();
|
|
|
286
|
- if(empty($accessToken)){
|
|
|
287
|
- $this->helpGo('/signin.html');
|
304
|
+ public function wechatbackAction()
|
|
|
305
|
+ {
|
|
|
306
|
+ $wechat = Factory::create('wechat');
|
|
|
307
|
+ $access = $wechat->getAccessToken();
|
|
|
308
|
+ /* 获取用户的详细信息 */
|
|
|
309
|
+ $partnerInfo = $wechat->getUserInfo($access);
|
|
|
310
|
+
|
|
|
311
|
+ $result = array();
|
|
|
312
|
+ if ($partnerInfo && is_array($partnerInfo)) {
|
|
|
313
|
+ $shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
314
|
+ $result = LoginData::signinByOpenID($partnerInfo['nickname'],$partnerInfo['openid'], 'wechat', $shoppingKey,$partnerInfo['openid']);
|
288
|
}
|
315
|
}
|
289
|
- if(!isset($accessToken['access_token']) || !isset($accessToken['unionid']) || empty($accessToken['access_token']) || empty($accessToken['unionid'])){
|
|
|
290
|
- $this->helpGo('/signin.html');
|
316
|
+
|
|
|
317
|
+ //判定是否需要绑定手机号
|
|
|
318
|
+ if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
|
|
|
319
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
320
|
+ $this->setSession('_TOKEN', $token);
|
|
|
321
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
322
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
323
|
+ $fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $partnerInfo['openid'], 'sourceType' => 'wechat', 'nickname' => $partnerInfo['nickname'])));
|
|
|
324
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
|
291
|
}
|
325
|
}
|
292
|
- $userInfo = QINWechat_Sdk_Open::getUserInfo($accessToken['access_token'], $accessToken['unionid']);
|
|
|
293
|
- if(empty($userInfo)){
|
|
|
294
|
- $this->helpGo('/signin.html');
|
326
|
+
|
|
|
327
|
+ $refer = $this->getCookie('refer');
|
|
|
328
|
+ if (empty($refer)) {
|
|
|
329
|
+ $refer = SITE_MAIN . '/?go=1';
|
295
|
}
|
330
|
}
|
296
|
- $this->wechatlogin($userInfo);
|
331
|
+ else {
|
|
|
332
|
+ $refer = rawurldecode($refer);
|
297
|
}
|
333
|
}
|
298
|
|
334
|
|
299
|
- /**
|
|
|
300
|
- * 微信登录
|
|
|
301
|
- * @param array $userInfo
|
|
|
302
|
- */
|
|
|
303
|
- public function wechatlogin($userInfo){
|
|
|
304
|
- if(empty($userInfo)){
|
|
|
305
|
- $this->helpGo('/signin.html');
|
|
|
306
|
- }
|
|
|
307
|
- try {
|
|
|
308
|
- $oauthUserInfo = QINAuth_User_Utils::check('wechat', $userInfo['unionid'], $userInfo['nickname'], null, $userInfo);
|
|
|
309
|
- $auth = QINAuth_Factory::profile('wechat');
|
|
|
310
|
- $res=$auth->associate($oauthUserInfo['email'], array(
|
|
|
311
|
- 'password' => QINAuth_User_Utils::$defaultPassword,
|
|
|
312
|
- 'open_id' => $userInfo['unionid'],
|
|
|
313
|
- 'nick_name' => $userInfo['nickname']
|
|
|
314
|
- ));
|
|
|
315
|
- } catch (Exception $e) {
|
|
|
316
|
- $this->helpSession('passport_space')->__set('error_message', 'wechat' . $e->getMessage());
|
|
|
317
|
- $this->helpGo('/signin.html');
|
|
|
318
|
- }
|
|
|
319
|
- //跳转到
|
|
|
320
|
- $url = $this->authInfo($res, 'wechat' , $oauthUserInfo['email']);
|
|
|
321
|
- $this->helpGo($url);
|
335
|
+ if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
|
|
|
336
|
+ $token = Helpers::makeToken($result['data']['uid']);
|
|
|
337
|
+ $this->setSession('_TOKEN', $token);
|
|
|
338
|
+ $this->setSession('_LOGIN_UID', $result['data']['uid']);
|
|
|
339
|
+ $this->setCookie('_TOKEN', $token);
|
|
|
340
|
+ $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
|
|
|
341
|
+ }
|
|
|
342
|
+ else {
|
|
|
343
|
+ $this->go($refer);
|
|
|
344
|
+ }
|
322
|
}
|
345
|
}
|
323
|
-
|
|
|
324
|
} |
346
|
} |