Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
4 changed files
with
81 additions
and
32 deletions
library/LibModels/Web/Home/UserData.php
0 → 100644
1 | +<?php | ||
2 | +namespace LibModels\Web\Home; | ||
3 | +use Api\Yohobuy; | ||
4 | +use Api\Sign; | ||
5 | +use Plugin\Helpers; | ||
6 | +class UserData extends \LibModels\Wap\Home\UserData | ||
7 | +{ | ||
8 | + /** | ||
9 | + * 根据手机号获取用户信息[TODO +cache] | ||
10 | + * | ||
11 | + * @param string $area | ||
12 | + * @param string $mobile | ||
13 | + * @return array | ||
14 | + */ | ||
15 | + public static function getUserInfoByMobile($area, $mobile) | ||
16 | + { | ||
17 | + $param = Yohobuy::param(); | ||
18 | + $param['method'] = 'app.passport.userlist'; | ||
19 | + $param['mobile'] = Helpers::makeMobile($area, $mobile); | ||
20 | + $param['debug'] = 'Y'; | ||
21 | + $param['screen_size'] = '320x568'; | ||
22 | + $param['client_secret'] = Sign::getSign($param); | ||
23 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * 根据email获取用户信息 | ||
28 | + * | ||
29 | + * @param string $email | ||
30 | + * @return array | ||
31 | + */ | ||
32 | + public static function getUserInfoByEmail($email) | ||
33 | + { | ||
34 | + $param = Yohobuy::param(); | ||
35 | + $param['method'] = 'app.passport.userlist'; | ||
36 | + $param['email'] = $email; | ||
37 | + $param['debug'] = 'Y'; | ||
38 | + $param['screen_size'] = '320x568'; | ||
39 | + $param['client_secret'] = Sign::getSign($param); | ||
40 | + return Yohobuy::post(Yohobuy::API_URL, $param); | ||
41 | + } | ||
42 | +} |
1 | <?php | 1 | <?php |
2 | namespace LibModels\Web\Passport; | 2 | namespace LibModels\Web\Passport; |
3 | -use Api\Yohobuy; | ||
4 | -use Api\Sign; | ||
5 | -use Plugin\Helpers; | ||
6 | class RegData extends \LibModels\Wap\Passport\RegData | 3 | class RegData extends \LibModels\Wap\Passport\RegData |
7 | { | 4 | { |
8 | 5 | ||
9 | - /** | ||
10 | - * 根据手机号获取用户信息[TODO +cache] | ||
11 | - * | ||
12 | - * @param string $area | ||
13 | - * @param string $mobile | ||
14 | - * @return string | ||
15 | - */ | ||
16 | - public static function getUserInfoByMobile($area, $mobile) | ||
17 | - { | ||
18 | - $param = Yohobuy::param(); | ||
19 | - $param['method'] = 'app.passport.userlist'; | ||
20 | - $param['mobile'] = Helpers::makeMobile($area, $mobile); | ||
21 | - $param['debug'] = 'Y'; | ||
22 | - $param['screen_size'] = '320x568'; | ||
23 | - $param['client_secret'] = Sign::getSign($param); | ||
24 | - return Yohobuy::post(Yohobuy::API_URL, $param); | ||
25 | - } | ||
26 | - | ||
27 | } | 6 | } |
@@ -4,7 +4,7 @@ namespace Passport; | @@ -4,7 +4,7 @@ namespace Passport; | ||
4 | 4 | ||
5 | use Plugin\Helpers; | 5 | use Plugin\Helpers; |
6 | use LibModels\Web\Home\IndexData; | 6 | use LibModels\Web\Home\IndexData; |
7 | -use LibModels\Web\Passport\RegData; | 7 | +use LibModels\Web\Home\UserData; |
8 | use Plugin\Images; | 8 | use Plugin\Images; |
9 | use Plugin\Captcha; | 9 | use Plugin\Captcha; |
10 | 10 | ||
@@ -113,7 +113,7 @@ class PassportModel | @@ -113,7 +113,7 @@ class PassportModel | ||
113 | */ | 113 | */ |
114 | public static function getUserInfoByMobile($area, $mobile) { | 114 | public static function getUserInfoByMobile($area, $mobile) { |
115 | $ret = array(); | 115 | $ret = array(); |
116 | - $data = RegData::getUserInfoByMobile($area, $mobile); | 116 | + $data = UserData::getUserInfoByMobile($area, $mobile); |
117 | if($data['code'] == 200) { | 117 | if($data['code'] == 200) { |
118 | if(!empty($data['data'])) { | 118 | if(!empty($data['data'])) { |
119 | $ret = current($data['data']); | 119 | $ret = current($data['data']); |
@@ -122,4 +122,20 @@ class PassportModel | @@ -122,4 +122,20 @@ class PassportModel | ||
122 | return $ret; | 122 | return $ret; |
123 | } | 123 | } |
124 | 124 | ||
125 | + /** | ||
126 | + * 根据邮箱获取用户信息 | ||
127 | + * | ||
128 | + * @param string $email | ||
129 | + * @return array | ||
130 | + */ | ||
131 | + public static function getUserInfoByEmail($email) { | ||
132 | + $ret = array(); | ||
133 | + $data = UserData::getUserInfoByEmail($email); | ||
134 | + if($data['code'] == 200) { | ||
135 | + if(!empty($data['data'])) { | ||
136 | + $ret = current($data['data']); | ||
137 | + } | ||
138 | + } | ||
139 | + return $ret; | ||
140 | + } | ||
125 | } | 141 | } |
@@ -30,15 +30,27 @@ class BackController extends WebAction { | @@ -30,15 +30,27 @@ class BackController extends WebAction { | ||
30 | /** | 30 | /** |
31 | * 校验验证码 | 31 | * 校验验证码 |
32 | */ | 32 | */ |
33 | - public function authcodeAction() { | ||
34 | - $phoneNum = $this->post ('phoneNum', ''); | ||
35 | - $area = intval ($this->post( 'area', '86' )); | ||
36 | - $verifyCode = $this->post ('verifyCode', ''); | ||
37 | - $data = array('code' => 400, 'message' =>'验证失败'); | ||
38 | - if ((Helpers::verifyEmail($phoneNum) || Helpers::verifyMobile($phoneNum)) | ||
39 | - && PassportModel::verifyCode($verifyCode)) { | ||
40 | - $data['code'] = 200; | ||
41 | - $data['message'] = '验证成功'; | 33 | + public function authcodeAction() |
34 | + { | ||
35 | + $phoneNum = $this->post('phoneNum', ''); | ||
36 | + $area = intval($this->post('area', '86')); | ||
37 | + $verifyCode = $this->post('verifyCode', ''); | ||
38 | + $data = array( | ||
39 | + 'code' => 200, | ||
40 | + 'message' => '验证成功' | ||
41 | + ); | ||
42 | + if (PassportModel::verifyCode($verifyCode)) { | ||
43 | + if (Helpers::verifyEmail($phoneNum)) { | ||
44 | + if (empty(PassportModel::getUserInfoByEmail($phoneNum))) { | ||
45 | + $data['message'] = '该账户不存在'; | ||
46 | + $data['code'] = 400; | ||
47 | + } | ||
48 | + } else if (Helpers::verifyMobile($phoneNum)) { | ||
49 | + if (empty(PassportModel::getUserInfoByMobile($phoneNum, $area))) { | ||
50 | + $data['message'] = '该账户不存在'; | ||
51 | + $data['code'] = 400; | ||
52 | + } | ||
53 | + } | ||
42 | } | 54 | } |
43 | echo $this->echoJson($data); | 55 | echo $this->echoJson($data); |
44 | } | 56 | } |
-
Please register or login to post a comment