Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
shijian
8 years ago
Commit
cf3eee2f78b8c8d8938e09c02e75ce3fa91fd547
2 parents
20d14d68
f401cc57
Merge branch 'feature/safe-bug' of
http://git.yoho.cn/fe/yoho-blk
into feature/safe-bug
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
47 deletions
apps/passport/controllers/captcha.js
apps/passport/controllers/login.js
apps/passport/router.js
public/js/passport/login/index.js
apps/passport/controllers/captcha.js
View file @
cf3eee2
...
...
@@ -57,6 +57,7 @@ const generate = (req, res) => {
let
length
=
+
(
req
.
query
.
l
||
4
);
let
captcha
=
captchaService
.
generateCaptcha
(
width
,
height
,
length
);
req
.
session
.
sendMobile
=
''
;
req
.
session
.
captcha
=
captcha
.
text
;
req
.
session
.
captchaCount
=
0
;
...
...
@@ -97,31 +98,9 @@ const requiredPost = (req, res) => {
}
};
const
checkSendMobile
=
(
req
,
res
,
fromNode
,
mobile
)
=>
{
if
(
fromNode
)
{
// node中判断
if
(
req
.
session
.
sendMobile
&&
req
.
session
.
sendMobile
!==
mobile
)
{
return
true
;
}
else
{
return
false
;
}
}
if
(
req
.
session
.
sendMobile
&&
req
.
session
.
sendMobile
!==
req
.
query
.
mobile
)
{
// ajax中判断
return
res
.
json
({
code
:
400
,
message
:
'验证码已失效'
});
}
else
{
return
res
.
json
({
code
:
200
,
data
:
{}
});
}
};
module
.
exports
=
{
requiredAPI
,
requiredPage
,
generate
,
requiredPost
,
checkSendMobile
requiredPost
};
...
...
apps/passport/controllers/login.js
View file @
cf3eee2
...
...
@@ -241,6 +241,15 @@ const local = {
message
:
'格式错误'
});
}
if
(
req
.
session
.
sendMobile
&&
req
.
session
.
sendMobile
!==
mobile
)
{
// ajax中判断
req
.
session
.
sendMobile
=
''
;
req
.
session
.
captcha
=
''
;
return
res
.
json
({
code
:
400
,
message
:
'验证码已失效'
});
}
LoginService
.
sendPasswordBySMS
(
area
,
mobile
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
===
200
)
{
...
...
apps/passport/router.js
View file @
cf3eee2
...
...
@@ -159,6 +159,5 @@ router.get('/back/resetSuccess',
router
.
get
(
'/images'
,
captcha
.
generate
);
router
.
post
(
'/images/check'
,
captcha
.
requiredPost
);
router
.
get
(
'/captcha/checkSendMobile'
,
captcha
.
checkSendMobile
);
module
.
exports
=
router
;
...
...
public/js/passport/login/index.js
View file @
cf3eee2
...
...
@@ -48,7 +48,7 @@ var upDown = {
var
selectedIcon
=
''
;
// 短信验证码的计数器,60s
var
secondCount
=
5
;
var
secondCount
=
60
;
// 短信验证码只能验证一次
var
isSmsCheckedSuccessFlag
=
false
;
...
...
@@ -486,7 +486,7 @@ ep.on('smsCode', function(auth) {
function
disable60sSendSmsBtn
()
{
secondCount
-=
1
;
if
(
secondCount
<
0
)
{
secondCount
=
5
;
secondCount
=
60
;
$smsBtn
.
val
(
'获取短信验证码'
)
.
removeClass
(
'second-progress'
)
.
removeClass
(
'disable'
);
...
...
@@ -509,7 +509,7 @@ function sendCaptchaSmsAsync() {
verifyCode
:
$
.
trim
(
$imgCaptchaInput
.
val
())
}
}).
then
(
function
(
data
)
{
if
(
data
.
captchaCount
===
false
)
{
if
(
data
.
captchaCount
===
false
||
data
.
code
===
400
)
{
errTip
(
$imgCaptchaInput
,
data
.
message
);
ep
.
emit
(
'captcha'
,
false
);
refreshCaptcha
();
...
...
@@ -659,26 +659,6 @@ $smsBtn.on('mousedown', function() {
return
validateCaptchaImg
(
true
);
})
.
then
(
function
()
{
var
defer
=
$
.
Deferred
();
return
$
.
ajax
({
type
:
'GET'
,
url
:
'/passport/captcha/checkSendMobile'
,
data
:
{
mobile
:
getMoblie
()
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
400
)
{
errTip
(
$imgCaptchaInput
,
data
.
message
);
ep
.
emit
(
'captcha'
,
false
);
refreshCaptcha
();
return
defer
.
reject
(
false
);
}
else
{
return
true
;
}
});
})
.
then
(
function
()
{
disable60sSendSmsBtn
();
return
sendCaptchaSmsAsync
();
});
...
...
Please
register
or
login
to post a comment