Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
whb
9 years ago
Commit
976667597a5228543c568da57d07008e92106cd1
1 parent
7085a6b3
找回密码
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
226 additions
and
226 deletions
template/www.yohobuy.com/actions/passport/back/verification.phtml
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Back.php
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Register.php
template/www.yohobuy.com/actions/passport/back/verification.phtml
View file @
9766675
...
...
@@ -22,8 +22,8 @@
</li>
<li>
<input
name=
"area"
id=
"area"
type=
"hidden"
value=
"{{area}}"
>
<input
name=
"mobile"
id=
"mobile"
type=
"hidden"
value=
"{{phoneNum}}"
>
<input
name=
"captchaPic"
id=
"captchaPic"
type=
"hidden"
value=
"{{captcha}}"
>
<input
name=
"mobile"
id=
"mobile"
type=
"hidden"
value=
"{{mobile}}"
>
<input
name=
"captchaPic"
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>
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Back.php
View file @
9766675
<?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
);
$this
->
setSession
(
'phoneNum'
,
$phoneNum
);
if
(
$data
[
'code'
]
==
200
)
{
$this
->
redirect
(
'sendemail'
);
}
else
{
$this
->
redirect
(
'index'
);
}
}
else
if
(
Helpers
::
verifyMobile
(
$phoneNum
))
{
//验证手机号
$mobile
=
$phoneNum
;
$data
=
BackData
::
sendCodeToMobile
(
$mobile
);
$this
->
setSession
(
'phoneNum'
,
$phoneNum
);
$this
->
setSession
(
'area'
,
$area
);
$this
->
setSession
(
'verifyCode'
,
$verifyCode
);
if
(
$data
[
'code'
]
==
200
)
{
$this
->
redirect
(
'verification'
);
}
else
{
$this
->
redirect
(
'index'
);
}
}
}
/**
* 发送邮件页面
*/
public
function
sendemailAction
()
{
$phoneNum
=
$this
->
getSession
(
'phoneNum'
);
if
(
empty
(
$phoneNum
))
{
$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
()
{
$phoneNum
=
$this
->
getSession
(
'phoneNum'
);
$area
=
$this
->
getSession
(
'area'
);
$verifyCode
=
$this
->
getSession
(
'verifyCode'
);
if
(
empty
(
$phoneNum
))
{
$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'
],
'phoneNum'
=>
$phoneNum
,
'area'
=>
$area
,
'captcha'
=>
$captcha
,
'countrys'
=>
array
()
)
);
$this
->
_view
->
display
(
'verification'
,
$data
);
}
/**
* 手机找回密码验证
*/
public
function
backmobileAction
()
{
$mobile
=
$this
->
post
(
'mobile'
);
//phoneNum
$area
=
$this
->
post
(
'area'
);
//$captcha = $this->post('captcha');
$code
=
$this
->
post
(
'captcha'
);
//code
if
(
$this
->
getSession
(
'phoneNum'
)
==
$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
()
{
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
);
$this
->
setSession
(
'email'
,
$email
);
if
(
$data
[
'code'
]
==
200
)
{
$this
->
redirect
(
'sendemail'
);
}
else
{
$this
->
redirect
(
'index'
);
}
}
else
if
(
Helpers
::
verifyMobile
(
$phoneNum
))
{
//验证手机号
$mobile
=
$phoneNum
;
$data
=
BackData
::
sendCodeToMobile
(
$mobile
);
$this
->
setSession
(
'mobile'
,
$mobile
);
$this
->
setSession
(
'area'
,
$area
);
$this
->
setSession
(
'verifyCode'
,
$verifyCode
);
if
(
$data
[
'code'
]
==
200
)
{
$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
;
}
}
\ No newline at end of file
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Register.php
View file @
9766675
...
...
@@ -22,7 +22,7 @@ class RegisterController extends WebAction
'region'
=>
RegData
::
getAreasData
(),
'location'
=>
'+86'
,
'captchaUrl'
=>
'/passport/images?t=1449799445'
,
'itemUrl'
=>
'
##
'
,
'itemUrl'
=>
'
http://www.yohobuy.com/help/?category_id=9
'
,
'referUrl'
=>
$refer
,
'loginUrl'
=>
'/signin.html?refer='
.
$refer
,
'coverHref'
=>
$cover
[
'url'
],
...
...
Please
register
or
login
to post a comment