Authored by hf

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

<?php
namespace LibModels\Web\Passport;
use Api\Sign;
use Api\Yohobuy;
class BackData extends \LibModels\Wap\Passport\BackData
{
/**
* 验证找回邮件code
*
* @param string $code
* @return array
*/
public static function checkEmailCode($code)
{
$param = Yohobuy::param();
$param['method'] = 'app.register.checkCodeValid';
$param['code'] = $code;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 缓存1小时
}
/**
* 根据邮箱code修改密码
*
* @param string $code
* @param string $password
* @return array
*/
public static function modifyPasswordByEmailCode($code, $password)
{
$param = Yohobuy::param();
$param['method'] = 'app.register.resetPwdByCode';
$param['code'] = $code;
$param['newPwd'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@ use Action\WebAction;
use LibModels\Web\Passport\RegData;
use Passport\PassportModel;
use Plugin\Helpers;
use LibModels\Wap\Passport\BackData;
use LibModels\Web\Passport\BackData;
use Plugin\AuthCode;
class BackController extends WebAction {
... ... @@ -43,14 +43,14 @@ class BackController extends WebAction {
if (Helpers::verifyEmail($phoneNum)) {
$ret = PassportModel::getUserInfoByEmail($phoneNum);
if (empty($ret)) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
$data['message'] = '该邮件账户不存在';
$data['code'] = 401;
}
} else if (Helpers::verifyMobile($phoneNum)) {
$ret = PassportModel::getUserInfoByMobile($area, $phoneNum);
if (empty($ret)) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
$data['message'] = '该手机号不存在';
$data['code'] = 402;
}
}
} else {
... ... @@ -135,7 +135,22 @@ class BackController extends WebAction {
{
$code = $this->get('code');
$info = $this->checkCode($code);
if (empty ( $info )) {
$verifyState = false;//验证状态
$ret = array();
if (!empty ( $info )) {
$verifyState = true;
if(isset($info['uid'])) { //老版修改邮箱密码
$verifyState = false;//重新找回密码
}
} else {
$ret = BackData::checkEmailCode($code);
if(isset($ret['data']) && $ret['code'] == 200) {
$verifyState = true;
}
}
//验证失败
if(!$verifyState)
{
$this->redirect ('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
... ... @@ -160,23 +175,29 @@ class BackController extends WebAction {
$code = $this->post('code');
$password = $this->post('pwd');
$info = $this->checkCode($code);
if (Helpers::verifyPassword ($password) && ! empty ($info)) {
// 修改密码
if (isset ( $info ['mobile'] )) { // 手机号修改密码
$mobile = $info ['mobile'];
$token = $info ['token'];
$area = $info ['area'];
$data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
if (Helpers::verifyPassword ($password)) {
if(!empty($info)) { //手机号找回
// 修改密码
if (isset ( $info ['mobile'] )) { // 手机号修改密码
$mobile = $info ['mobile'];
$token = $info ['token'];
$area = $info ['area'];
$data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
if ($data ['code'] == 200) {
$this->redirect ( 'resetSuccess' );
}
} else if (isset ($info ['uid'])) { //其他方式修改密码,跳到找回密码首页
$this->redirect ( '/index' );
}
} else { //新版邮箱修改接口
$data = BackData::modifyPasswordByEmailCode($code, $password);
if ($data ['code'] == 200) {
$this->redirect ( 'resetSuccess' );
}
} else if (isset ($info ['uid'])) { // 其他方式修改密码
$uid = $info ['uid'];
$this->redirect ( 'resetSuccess' );
}
}
// 跳转错误页面
$this->redirect('/error/index');
$this->redirect('/index');
}
/**
... ...