Authored by whb

找回密码

... ... @@ -16,7 +16,7 @@
</ul>
</div>
<form id="back-form" class="back-form" action="/passport/back/email" method="post">
<input id="country-code-hide" type="hidden" name="country-code" value="+86">
<input id="country-code-hide" type="hidden" name="area" value="+86">
<ul>
<li class="input-container-li clearfix">
<input id="phone-num" class="input va phone-num" type="text" name="phoneNum" placeholder="邮箱/手机号码" autocomplete="off">
... ... @@ -27,7 +27,7 @@
</span>
</li>
<li class="input-container-li clearfix">
<input id="captcha" class="input va captcha" type="text" name="captcha" placeholder="验证码" autocomplete="off" maxlength="4">
<input id="captcha" class="input va captcha" type="text" name="verifyCode" placeholder="验证码" autocomplete="off" maxlength="4">
<img id="captcha-img" class="captcha-img" src="{{captchaUrl}}" alt="">
<a id="change-captcha" class="link change-captcha">换一张</a>
<span id="captcha-err" class="err-tip captcha-err hide">
... ...
... ... @@ -12,7 +12,7 @@
<span class="phone-num">{{mobile}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="captcha" class="input va captcha" type="text" name="code">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
... ... @@ -23,7 +23,7 @@
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{mobile}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="{{verifyCode}}">
<input name="verifyCode" id="captchaPic" type="hidden" value="{{verifyCode}}">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
... ...
/**
* 找回密码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/14
*/
var $ = require('yoho.jquery'),
phoneRegx = require('./mail-phone-regx').phoneRegx;
var $cr = $('#country-code-hide'),
$phoneNum = $('#phone-num'),
$ca = $('#captcha'),
$tipPanel = $('#tip-panel'),
emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/,
acAccount = [
['qq.com', '163.com', '126.com', 'sina.com', 'gmail.com',
'sohu.com', 'hotmail.com', '139.com', '189.com'], //数字顺序
['gmail.com', 'qq.com', '163.com', '126.com', 'sina.com',
'sohu.com', 'hotmail.com', '139.com', '189.com'] //组合顺序
],
$ccList = $('#country-code-list'),
$cc = $('#country-code'),
$btn = $('#find-btn'),
$accErr = $('#account-err'),
$caErr = $('#captcha-err'),
time, //timeout-id
caCount = 4, //验证码位数
hasPh = false,
hasCa = false;
require('yoho.placeholder');
/*function getSource(column, postition, event) {
try {
dataLayer.push({
louceng: column,
weizhi: postition,
event: event
});
} catch (e) {}
}*/
function imgcode() {
$('#captcha-img').attr('src', 'http://www.yohobuy.com/passport/images?t=' + Math.random());
//getSource('yoho_family_web', '换一张', 'homepage_man');
}
function enableBtn() {
if (hasPh && hasCa) {
$btn.removeClass('disable').prop('disabled', false);
} else {
$btn.addClass('disable').prop('disabled', true);
}
}
function vaPn(v) {
var pass = true,
errTxt = '';
v = $.trim(v);
if (v !== '') {
if (/^[0-9]+$/.test(v)) {
if (phoneRegx[$cr.val()].test(v)) {
pass = true;
} else {
errTxt = '手机号码格式不正确, 请重新输入';
pass = false;
}
} else {
if (emailReg.test(v)) {
pass = true;
} else {
errTxt = '邮箱格式不正确, 请重新输入';
pass = false;
}
}
} else {
errTxt = '账户名不能为空';
pass = false;
}
hasPh = pass;
return {
pass: pass,
errTxt: errTxt
};
}
function vaCa() {
var v = $.trim($ca.val());
if (v === '' || v.length < caCount) {
hasCa = false;
enableBtn();
return;
} else {
$.ajax({
type: 'POST',
url: '/passport/back/authcode',
data: {
code: v,
mobile: $('#phone-num').val(),
area: $('#country-code-hide').val()
}
}).then(function(data) {
if (data.code === 200) {
hasCa = true;
} else {
hasCa = false;
imgcode();
}
enableBtn();
});
}
}
$ca.attr('maxlength', caCount);
//IE8 placeholder
$('input').placeholder();
$('#change-captcha, #captcha-img').on('click', function() {
imgcode();
});
$cc.on('click', function(e) {
e.stopPropagation();
if ($ccList.css('style') === 'block') {
$ccList.slideUp('fast');
} else {
$ccList.slideDown('fast');
}
});
$ccList.delegate('li', 'click', function(e) {
var $cur = $(this),
code = $cur.data('cc'),
pnVa;
e.stopPropagation();
$cr.val(code);
$cc.find('em').html($cur.text());
//切换后验证手机号码
if ($.trim($phoneNum.val()) !== '') {
pnVa = vaPn($phoneNum.val());
enableBtn();
if (hasPh) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').text(pnVa.errTxt);
$phoneNum.addClass('error');
}
}
$ccList.slideUp('fast');
});
$(document).click(function() {
if ($tipPanel.css('display') === 'block') {
$tipPanel.slideUp();
}
if ($ccList.css('display') === 'block') {
$ccList.slideUp();
}
});
$phoneNum.keyup(function() {
var account = $.trim($(this).val()),
html = '',
acs,
i;
//输入@时显示自动补全列表
if (account.indexOf('@') !== -1 && account.lastIndexOf('@') === account.indexOf('@')) {
if (/^[0-9]*@$/.test(account)) {
//数字顺序
acs = acAccount[0];
} else {
acs = acAccount[1];
}
for (i = 0; i < acs.length; i++) {
html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + acs[i] + '</li>';
}
$tipPanel.html(html).slideDown();
} else {
$tipPanel.slideUp();
}
vaPn(account);
enableBtn();
}).blur(function() {
time = setTimeout(function() {
var pnVa = vaPn($phoneNum.val());
if (pnVa.pass) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').find('em').text(pnVa.errTxt);
$phoneNum.addClass('error');
}
}, 170);
}).focus(function() {
$(this).removeClass('error');
//focus隐藏错误提示
$accErr.addClass('hide');
});
//验证码在鼠标移开后验证, keyup时不再验证
$ca.blur(function() {
var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';
if (hasCa) {
$caErr.addClass('hide');
$ca.removeClass('error');
} else {
$caErr.removeClass('hide').find('em').text(errTxt);
$ca.addClass('error');
//验证码错误则刷新验证码
imgcode();
}
}).focus(function() {
$(this).removeClass('error');
//focus隐藏错误提示
$caErr.addClass('hide');
}).keyup(function() {
vaCa();
});
$tipPanel.delegate('li', 'click', function(e) {
var account = $(this).text(),
pnVa;
e.stopPropagation();
$phoneNum.val(account);
if (time) {
clearTimeout(time);
pnVa = vaPn(account);
enableBtn();
if (pnVa.pass) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').find('em').text(pnVa.errTx);
$phoneNum.addClass('error');
}
time = null;
}
$tipPanel.slideUp();
});
$('#find-btn').click(function(e) {
//getSource('yoho_family_web', '下一步按钮', 'homepage_man');
if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
$('#find-form').attr('action', '/passport/back/mobile');
}
if ($(this).hasClass('disable')) {
return;
}
if (!hasCa || !hasPh) {
e.preventDefault();
return true;
}
/**
* 找回密码
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/12/14
*/
var $ = require('yoho.jquery'),
phoneRegx = require('./mail-phone-regx').phoneRegx;
var $cr = $('#country-code-hide'),
$phoneNum = $('#phone-num'),
$ca = $('#captcha'),
$tipPanel = $('#tip-panel'),
emailReg = /^[.\-_a-zA-Z0-9]+@[\-_a-zA-Z0-9]+\.[a-zA-Z0-9]/,
acAccount = [
['qq.com', '163.com', '126.com', 'sina.com', 'gmail.com',
'sohu.com', 'hotmail.com', '139.com', '189.com'], //数字顺序
['gmail.com', 'qq.com', '163.com', '126.com', 'sina.com',
'sohu.com', 'hotmail.com', '139.com', '189.com'] //组合顺序
],
$ccList = $('#country-code-list'),
$cc = $('#country-code'),
$btn = $('#find-btn'),
$accErr = $('#account-err'),
$caErr = $('#captcha-err'),
time, //timeout-id
caCount = 4, //验证码位数
hasPh = false,
hasCa = false;
require('yoho.placeholder');
/*function getSource(column, postition, event) {
try {
dataLayer.push({
louceng: column,
weizhi: postition,
event: event
});
} catch (e) {}
}*/
function imgcode() {
var time = new Date(),
$captchaImg = $('#captcha-img'),
captchaImgSrc = $captchaImg.attr('src').split('?')[0];
$('#captcha-img').attr('src', captchaImgSrc + '?t=' + time.getTime());
//getSource('yoho_family_web', '换一张', 'homepage_man');
}
function enableBtn() {
if (hasPh && hasCa) {
$btn.removeClass('disable').prop('disabled', false);
} else {
$btn.addClass('disable').prop('disabled', true);
}
}
function vaPn(v) {
var pass = true,
errTxt = '';
v = $.trim(v);
if (v !== '') {
if (/^[0-9]+$/.test(v)) {
if (phoneRegx[$cr.val()].test(v)) {
pass = true;
} else {
errTxt = '手机号码格式不正确, 请重新输入';
pass = false;
}
} else {
if (emailReg.test(v)) {
pass = true;
} else {
errTxt = '邮箱格式不正确, 请重新输入';
pass = false;
}
}
} else {
errTxt = '账户名不能为空';
pass = false;
}
hasPh = pass;
return {
pass: pass,
errTxt: errTxt
};
}
function vaCa() {
var v = $.trim($ca.val());
if (v === '' || v.length < caCount) {
hasCa = false;
enableBtn();
return;
} else {
$.ajax({
type: 'POST',
url: '/passport/back/authcode',
data: {
verifyCode: v,
phoneNum: $('#phone-num').val(),
area: $('#country-code-hide').val()
}
}).then(function(data) {
if (data.code === 200) {
hasCa = true;
} else {
hasCa = false;
imgcode();
}
enableBtn();
});
}
}
$ca.attr('maxlength', caCount);
//IE8 placeholder
$('input').placeholder();
$('#change-captcha, #captcha-img').on('click', function() {
imgcode();
});
$cc.on('click', function(e) {
e.stopPropagation();
if ($ccList.css('style') === 'block') {
$ccList.slideUp('fast');
} else {
$ccList.slideDown('fast');
}
});
$ccList.delegate('li', 'click', function(e) {
var $cur = $(this),
code = $cur.data('cc'),
pnVa;
e.stopPropagation();
$cr.val(code);
$cc.find('em').html($cur.text());
//切换后验证手机号码
if ($.trim($phoneNum.val()) !== '') {
pnVa = vaPn($phoneNum.val());
enableBtn();
if (hasPh) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').text(pnVa.errTxt);
$phoneNum.addClass('error');
}
}
$ccList.slideUp('fast');
});
$(document).click(function() {
if ($tipPanel.css('display') === 'block') {
$tipPanel.slideUp();
}
if ($ccList.css('display') === 'block') {
$ccList.slideUp();
}
});
$phoneNum.keyup(function() {
var account = $.trim($(this).val()),
html = '',
acs,
i;
//输入@时显示自动补全列表
if (account.indexOf('@') !== -1 && account.lastIndexOf('@') === account.indexOf('@')) {
if (/^[0-9]*@$/.test(account)) {
//数字顺序
acs = acAccount[0];
} else {
acs = acAccount[1];
}
for (i = 0; i < acs.length; i++) {
html += '<li>' + account.slice(0, account.indexOf('@')) + '@' + acs[i] + '</li>';
}
$tipPanel.html(html).slideDown();
} else {
$tipPanel.slideUp();
}
vaPn(account);
enableBtn();
}).blur(function() {
time = setTimeout(function() {
var pnVa = vaPn($phoneNum.val());
if (pnVa.pass) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').find('em').text(pnVa.errTxt);
$phoneNum.addClass('error');
}
}, 170);
}).focus(function() {
$(this).removeClass('error');
//focus隐藏错误提示
$accErr.addClass('hide');
});
//验证码在鼠标移开后验证, keyup时不再验证
$ca.blur(function() {
var errTxt = $.trim($ca.val()) === '' ? '验证码不能为空' : '验证码不正确';
if (hasCa) {
$caErr.addClass('hide');
$ca.removeClass('error');
} else {
$caErr.removeClass('hide').find('em').text(errTxt);
$ca.addClass('error');
//验证码错误则刷新验证码
imgcode();
}
}).focus(function() {
$(this).removeClass('error');
//focus隐藏错误提示
$caErr.addClass('hide');
}).keyup(function() {
vaCa();
});
$tipPanel.delegate('li', 'click', function(e) {
var account = $(this).text(),
pnVa;
e.stopPropagation();
$phoneNum.val(account);
if (time) {
clearTimeout(time);
pnVa = vaPn(account);
enableBtn();
if (pnVa.pass) {
$accErr.addClass('hide');
$phoneNum.removeClass('error');
} else {
$accErr.removeClass('hide').find('em').text(pnVa.errTx);
$phoneNum.addClass('error');
}
time = null;
}
$tipPanel.slideUp();
});
$('#find-btn').click(function(e) {
//getSource('yoho_family_web', '下一步按钮', 'homepage_man');
if (/^[0-9]+$/.test($.trim($phoneNum.val()))) {
$('#find-form').attr('action', '/passport/back/mobile');
}
if ($(this).hasClass('disable')) {
return;
}
if (!hasCa || !hasPh) {
e.preventDefault();
return true;
}
});
\ No newline at end of file
... ...
<?php
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use Passport\PassportModel;
use Plugin\Helpers;
use LibModels\Wap\Passport\BackData;
use Plugin\AuthCode;
class BackController extends WebAction
{
/**
* 找回密码
*/
public function indexAction()
{
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'backPage' => true,
'back' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countryCode' => '86',
'countryName' => '中国',
'captchaUrl'=>'/passport/images?t=1449799445',
'countryList' => RegData::getAreasData(),
)
);
$this->_view->display('index', $data);
}
public function authcodeAction()
{
echo $this->echoJson(array('code'=> 200));
}
/**
*
*/
public function emailAction()
{
$phoneNum = $this->post('phoneNum','');
$area = $this->post('area','86');
$verifyCode = $this->post('verifyCode','');
if(Helpers::verifyEmail($phoneNum)){ //验证邮箱
$email = $phoneNum;
$data = BackData::sendCodeToEmail($email);
if($data['code'] == 200) {
$this->setSession('email', $email);
$this->redirect('sendemail');
}
else {
$this->redirect('index');
}
} else if(Helpers::verifyMobile($phoneNum)) {//验证手机号
$mobile = $phoneNum;
$data = BackData::sendCodeToMobile($mobile);
if($data['code'] == 200) {
$this->setSession('mobile', $mobile);
$this->setSession('area', $area);
$this->setSession('verifyCode', $verifyCode);
$this->redirect('verification');
}
else {
$this->redirect('index');
}
}
}
/**
* 发送邮件页面
*/
public function sendemailAction() {
$email = $this->getSession('email');
if(empty($email)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'sendEmail' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array(),
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码页面
*/
public function backcodeAction() {
$code = $this->get('code');
$info = $this->checkCode($code);
if(empty($info)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'resetPage' => true,
'resetPwd' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array(),
'code' => $code,
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码接口
*
*/
public function updateAction()
{
$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($data['code']) {
$this->redirect('resetSuccess');
}
} else if(isset($info['uid'])) {//其他方式修改密码
$uid = $info['uid'];
$this->redirect('resetSuccess');
}
}
//跳转错误页面
$this->redirect('/error/index');
}
/**
* 重置密码成功
*/
public function resetSuccessAction() {
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'resetSuccess' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
)
);
$this->_view->display('reset-success', $data);
}
/**
* 手机验证页面
*/
public function verificationAction() {
$mobile = $this->getSession('mobile');
$area = $this->getSession('area');
$verifyCode = $this->getSession('verifyCode');
if(empty($mobile)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
'vertificationPage' => true,
'verification' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'mobile' => $mobile,
'area' => $area,
'verifyCode'=> $verifyCode,
'countrys' => array()
)
);
$this->_view->display('verification', $data);
}
/**
* 手机找回密码验证
*/
public function backmobileAction()
{
$mobile = $this->post('mobile');
$area = $this->post('area');
$verifyCode = $this->post('verifyCode');
$code = $this->post('code');//code
if($this->getSession('mobile') == $mobile && $this->getSession('area') == $area)
{
$result = BackData::validateMobileCode($mobile, $code, $area);
if($result['code'] == 200) {
$str = json_encode(array(
'mobile'=> $mobile,
'area' => $area,
'token'=> $result['data']['token'],
'create_time' => time()
));
$code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
$url = '/passport/back/backcode?code='.base64_encode($code);
$this->redirect(SITE_MAIN.$url);
}
}
}
/**
* 检查code
*
* @param string $code
* @return boolean
*/
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) {
return array();
}
return $info;
}
<?php
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use Passport\PassportModel;
use Plugin\Helpers;
use LibModels\Wap\Passport\BackData;
use Plugin\AuthCode;
class BackController extends WebAction {
/**
* 找回密码
*/
public function indexAction() {
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader(false),
'backPage' => true,
'back' => array (
'coverHref' => $banner ['url'],
'coverImg' => $banner ['img'],
'countryCode' => '86',
'countryName' => '中国',
'captchaUrl' => '/passport/images?t=1449799445',
'countryList' => RegData::getAreasData()
)
);
$this->_view->display ( 'index', $data );
}
/**
* 校验验证码
*/
public function authcodeAction() {
$phoneNum = $this->post ('phoneNum', '');
$area = intval ($this->post( 'area', '86' ));
$verifyCode = $this->post ('verifyCode', '');
$data = array('code' => 400, 'message' =>'验证失败');
if ((Helpers::verifyEmail($phoneNum) || Helpers::verifyMobile($phoneNum))
&& PassportModel::verifyCode($verifyCode)) {
$data['code'] = 200;
$data['message'] = '验证成功';
}
echo $this->echoJson($data);
}
/**
* 邮箱
*/
public function emailAction() {
$phoneNum = $this->post ('phoneNum', '');
$area = intval ($this->post('area', '86'));
$verifyCode = $this->post('verifyCode', '');
if (Helpers::verifyEmail($phoneNum)) { // 验证邮箱
$email = $phoneNum;
$data = BackData::sendCodeToEmail($email);
if ($data ['code'] == 200) {
$this->setSession('email', $email);
$this->redirect ('sendemail');
} else {
$this->redirect ('index');
}
} else if (Helpers::verifyMobile($phoneNum)) { // 验证手机号
$mobile = $phoneNum;
$data = BackData::sendCodeToMobile($mobile, $area);
if ($data ['code'] == 200) {
$this->setSession ('mobile', $mobile );
$this->setSession ('area', $area );
$this->setSession ('verifyCode', $verifyCode );
$this->redirect ('verification');
} else {
$this->redirect ('index');
}
}
}
/**
* 发送邮件页面
*/
public function sendemailAction() {
$email = $this->getSession ('email');
if (empty ( $email )) {
$this->redirect ('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader(false),
'sendEmail' => array (
'coverHref' => $banner ['url'],
'coverImg' => $banner ['img'],
'countrys' => array ()
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码页面
*/
public function backcodeAction() {
$code = $this->get('code');
$info = $this->checkCode($code);
if (empty ( $info )) {
$this->redirect ('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader(false),
'resetPage' => true,
'resetPwd' => array (
'coverHref' => $banner ['url'],
'coverImg' => $banner ['img'],
'countrys' => array(),
'code' => $code
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码接口
*/
public function updateAction() {
$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 ($data ['code'] == 200) {
$this->redirect ( 'resetSuccess' );
}
} else if (isset ($info ['uid'])) { // 其他方式修改密码
$uid = $info ['uid'];
$this->redirect ( 'resetSuccess' );
}
}
// 跳转错误页面
// $this->redirect('/error/index');
}
/**
* 重置密码成功
*/
public function resetSuccessAction() {
$banner = PassportModel::getLeftBanner ( PassportModel::BACK_LFFT_BANNER_CODE );
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader ( false ),
'resetSuccess' => array (
'coverHref' => $banner ['url'],
'coverImg' => $banner ['img'],
'countrys' => array ()
)
);
$this->_view->display ( 'reset-success', $data );
}
/**
* 手机验证页面
*/
public function verificationAction() {
$mobile = $this->getSession ('mobile');
$area = $this->getSession ('area');
$verifyCode = $this->getSession ('verifyCode');
if (empty ($mobile)) {
$this->redirect ('index');
}
$banner = PassportModel::getLeftBanner (PassportModel::BACK_LFFT_BANNER_CODE);
$data = array (
'simpleHeader' => PassportModel::getSimpleHeader ( false ),
'vertificationPage' => true,
'verification' => array (
'coverHref' => $banner ['url'],
'coverImg' => $banner ['img'],
'mobile' => $mobile,
'area' => $area,
'verifyCode' => $verifyCode,
'countrys' => array ()
)
);
$this->_view->display ('verification', $data);
}
/**
* 手机找回密码验证
*/
public function backmobileAction() {
$mobile = $this->post ( 'mobile' );
$area = $this->post ( 'area' );
$verifyCode = $this->post ( 'verifyCode' );
$code = $this->post ( 'code' ); // code
if ($this->getSession ( 'mobile' ) == $mobile && $this->getSession ( 'area' ) == $area) {
$result = BackData::validateMobileCode ( $mobile, $code, $area );
if ($result ['code'] == 200) {
$str = json_encode ( array (
'mobile' => $mobile,
'area' => $area,
'token' => $result ['data'] ['token'],
'create_time' => time ()
) );
$code = AuthCode::encode ( $str, PassportModel::BACK_FIND_SECRET_KEY );
$url = '/passport/back/backcode?code=' . base64_encode ( $code );
$this->redirect ( SITE_MAIN . $url );
}
}
}
/**
* 检查code
*
* @param string $code
* @return boolean
*/
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) {
return array ();
}
return $info;
}
}
\ No newline at end of file
... ...