Authored by whb

手机验证

@@ -80,7 +80,8 @@ $('#captcha').keyup(function() { @@ -80,7 +80,8 @@ $('#captcha').keyup(function() {
80 url: '/passport/back/backmobile', 80 url: '/passport/back/backmobile',
81 dataType: 'json', 81 dataType: 'json',
82 data: { 82 data: {
83 - verifyCode: $('#captcha').val(), 83 + code: $('#captcha').val(),
  84 + verifyCode: $("#captchaPic").val(),
84 area: $('#area').val(), 85 area: $('#area').val(),
85 mobile: $('#mobile').val() 86 mobile: $('#mobile').val()
86 }, 87 },
@@ -46,11 +46,14 @@ class BackController extends WebAction { @@ -46,11 +46,14 @@ class BackController extends WebAction {
46 $data['code'] = 400; 46 $data['code'] = 400;
47 } 47 }
48 } else if (Helpers::verifyMobile($phoneNum)) { 48 } else if (Helpers::verifyMobile($phoneNum)) {
49 - if (empty(PassportModel::getUserInfoByMobile($phoneNum, $area))) { 49 + if (empty(PassportModel::getUserInfoByMobile($area, $phoneNum))) {
50 $data['message'] = '该账户不存在'; 50 $data['message'] = '该账户不存在';
51 $data['code'] = 400; 51 $data['code'] = 400;
52 } 52 }
53 } 53 }
  54 + } else {
  55 + $data['message'] = '验证失败';
  56 + $data['code'] = 400;
54 } 57 }
55 echo $this->echoJson($data); 58 echo $this->echoJson($data);
56 } 59 }
@@ -126,7 +129,8 @@ class BackController extends WebAction { @@ -126,7 +129,8 @@ class BackController extends WebAction {
126 /** 129 /**
127 * 重置密码页面 130 * 重置密码页面
128 */ 131 */
129 - public function backcodeAction() { 132 + public function backcodeAction()
  133 + {
130 $code = $this->get('code'); 134 $code = $this->get('code');
131 $info = $this->checkCode($code); 135 $info = $this->checkCode($code);
132 if (empty ( $info )) { 136 if (empty ( $info )) {
@@ -149,7 +153,8 @@ class BackController extends WebAction { @@ -149,7 +153,8 @@ class BackController extends WebAction {
149 /** 153 /**
150 * 更新密码接口 154 * 更新密码接口
151 */ 155 */
152 - public function updateAction() { 156 + public function updateAction()
  157 + {
153 $code = $this->post('code'); 158 $code = $this->post('code');
154 $password = $this->post('pwd'); 159 $password = $this->post('pwd');
155 $info = $this->checkCode($code); 160 $info = $this->checkCode($code);
@@ -175,7 +180,8 @@ class BackController extends WebAction { @@ -175,7 +180,8 @@ class BackController extends WebAction {
175 /** 180 /**
176 * 重置密码成功 181 * 重置密码成功
177 */ 182 */
178 - public function resetSuccessAction() { 183 + public function resetSuccessAction()
  184 + {
179 $banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE ); 185 $banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE );
180 $data = array ( 186 $data = array (
181 'simpleHeader' => PassportModel::getSimpleHeader ( false ), 187 'simpleHeader' => PassportModel::getSimpleHeader ( false ),
@@ -191,7 +197,8 @@ class BackController extends WebAction { @@ -191,7 +197,8 @@ class BackController extends WebAction {
191 /** 197 /**
192 * 手机验证页面 198 * 手机验证页面
193 */ 199 */
194 - public function verificationAction() { 200 + public function verificationAction()
  201 + {
195 $mobile = $this->getSession ('mobile'); 202 $mobile = $this->getSession ('mobile');
196 $area = $this->getSession ('area'); 203 $area = $this->getSession ('area');
197 $verifyCode = $this->getSession ('verifyCode'); 204 $verifyCode = $this->getSession ('verifyCode');
@@ -217,13 +224,14 @@ class BackController extends WebAction { @@ -217,13 +224,14 @@ class BackController extends WebAction {
217 /** 224 /**
218 * 手机找回密码验证 225 * 手机找回密码验证
219 */ 226 */
220 - public function backmobileAction() { 227 + public function backmobileAction()
  228 + {
221 $mobile = $this->post ( 'mobile' ); 229 $mobile = $this->post ( 'mobile' );
222 $area = $this->post ( 'area' ); 230 $area = $this->post ( 'area' );
223 $verifyCode = $this->post ( 'verifyCode' ); 231 $verifyCode = $this->post ( 'verifyCode' );
224 $code = $this->post ( 'code' ); // code 232 $code = $this->post ( 'code' ); // code
225 $data = array('code'=> 400, 'message' => '验证码错误!','data' => SITE_MAIN.'/passport/back/index'); 233 $data = array('code'=> 400, 'message' => '验证码错误!','data' => SITE_MAIN.'/passport/back/index');
226 - if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area) { 234 + if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area && ! empty($code)) {
227 $result = BackData::validateMobileCode ( $mobile, $code, $area ); 235 $result = BackData::validateMobileCode ( $mobile, $code, $area );
228 if ($result ['code'] == 200) { 236 if ($result ['code'] == 200) {
229 $str = json_encode ( array ( 237 $str = json_encode ( array (
@@ -248,7 +256,8 @@ class BackController extends WebAction { @@ -248,7 +256,8 @@ class BackController extends WebAction {
248 * @param string $code 256 * @param string $code
249 * @return boolean 257 * @return boolean
250 */ 258 */
251 - private function checkCode($code) { 259 + private function checkCode($code)
  260 + {
252 $code = base64_decode ( $code ); 261 $code = base64_decode ( $code );
253 $info = json_decode ( AuthCode::decode ( $code, PassportModel::BACK_FIND_SECRET_KEY ), true ); 262 $info = json_decode ( AuthCode::decode ( $code, PassportModel::BACK_FIND_SECRET_KEY ), true );
254 if ($info ['create_time'] < 1 || (time () - $info ['create_time']) > 86400) { 263 if ($info ['create_time'] < 1 || (time () - $info ['create_time']) > 86400) {