Authored by whb

手机验证

... ... @@ -80,7 +80,8 @@ $('#captcha').keyup(function() {
url: '/passport/back/backmobile',
dataType: 'json',
data: {
verifyCode: $('#captcha').val(),
code: $('#captcha').val(),
verifyCode: $("#captchaPic").val(),
area: $('#area').val(),
mobile: $('#mobile').val()
},
... ...
... ... @@ -46,11 +46,14 @@ class BackController extends WebAction {
$data['code'] = 400;
}
} else if (Helpers::verifyMobile($phoneNum)) {
if (empty(PassportModel::getUserInfoByMobile($phoneNum, $area))) {
if (empty(PassportModel::getUserInfoByMobile($area, $phoneNum))) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
}
}
} else {
$data['message'] = '验证失败';
$data['code'] = 400;
}
echo $this->echoJson($data);
}
... ... @@ -126,7 +129,8 @@ class BackController extends WebAction {
/**
* 重置密码页面
*/
public function backcodeAction() {
public function backcodeAction()
{
$code = $this->get('code');
$info = $this->checkCode($code);
if (empty ( $info )) {
... ... @@ -149,7 +153,8 @@ class BackController extends WebAction {
/**
* 更新密码接口
*/
public function updateAction() {
public function updateAction()
{
$code = $this->post('code');
$password = $this->post('pwd');
$info = $this->checkCode($code);
... ... @@ -175,7 +180,8 @@ class BackController extends WebAction {
/**
* 重置密码成功
*/
public function resetSuccessAction() {
public function resetSuccessAction()
{
$banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE );
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader ( false ),
... ... @@ -191,7 +197,8 @@ class BackController extends WebAction {
/**
* 手机验证页面
*/
public function verificationAction() {
public function verificationAction()
{
$mobile = $this->getSession ('mobile');
$area = $this->getSession ('area');
$verifyCode = $this->getSession ('verifyCode');
... ... @@ -217,13 +224,14 @@ class BackController extends WebAction {
/**
* 手机找回密码验证
*/
public function backmobileAction() {
public function backmobileAction()
{
$mobile = $this->post ( 'mobile' );
$area = $this->post ( 'area' );
$verifyCode = $this->post ( 'verifyCode' );
$code = $this->post ( 'code' ); // code
$data = array('code'=> 400, 'message' => '验证码错误!','data' => SITE_MAIN.'/passport/back/index');
if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area) {
if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area && ! empty($code)) {
$result = BackData::validateMobileCode ( $mobile, $code, $area );
if ($result ['code'] == 200) {
$str = json_encode ( array (
... ... @@ -248,7 +256,8 @@ class BackController extends WebAction {
* @param string $code
* @return boolean
*/
private function checkCode($code) {
private function checkCode($code)
{
$code = base64_decode ( $code );
$info = json_decode ( AuthCode::decode ( $code, PassportModel::BACK_FIND_SECRET_KEY ), true );
if ($info ['create_time'] < 1 || (time () - $info ['create_time']) > 86400) {
... ...