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
Email Patches
Plain Diff
Browse Files
Authored by
王水玲
8 years ago
Commit
bc0be2aa0a7699628b017c9bcd167b95bf056396
1 parent
d2972432
快捷登录修改 添加发送短信图形校验次数
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
apps/passport/controllers/captcha.js
apps/passport/router.js
public/js/passport/login/index.js
apps/passport/controllers/captcha.js
View file @
bc0be2a
...
...
@@ -13,6 +13,17 @@ const helpers = global.yoho.helpers;
*/
const
requiredAPI
=
(
req
,
res
,
next
)
=>
{
let
captchaToken
=
req
.
body
.
verifyCode
||
''
;
let
count
=
req
.
session
.
captchaCount
;
if
(
count
>=
4
)
{
return
res
.
json
({
code
:
403
,
captchaCount
:
false
,
message
:
'该验证码已失效'
});
}
req
.
session
.
captchaCount
=
count
+
1
;
if
(
captchaToken
===
req
.
session
.
captcha
)
{
return
next
();
...
...
@@ -47,6 +58,7 @@ const generate = (req, res) => {
let
captcha
=
captchaService
.
generateCaptcha
(
width
,
height
,
length
);
req
.
session
.
captcha
=
captcha
.
text
;
req
.
session
.
captchaCount
=
0
;
res
.
writeHead
(
200
,
{
'Content-Type'
:
'image/png'
...
...
@@ -60,6 +72,17 @@ const generate = (req, res) => {
*/
const
requiredPost
=
(
req
,
res
)
=>
{
let
captchaToken
=
req
.
body
.
verifyCode
||
''
;
let
count
=
req
.
session
.
captchaCount
;
if
(
count
>=
4
)
{
return
res
.
json
({
code
:
403
,
captchaCount
:
false
,
message
:
'该验证码已失效'
});
}
req
.
session
.
captchaCount
=
count
+
1
;
if
(
captchaToken
===
req
.
session
.
captcha
)
{
return
res
.
json
({
...
...
apps/passport/router.js
View file @
bc0be2a
...
...
@@ -24,7 +24,7 @@ router.post('/login/user', back.validateInputAPI, back.getUserInfoAPI);
router
.
get
(
'/logout'
,
login
.
local
.
logout
);
// 手机短信验证码
router
.
post
(
'/login/sms/send'
,
login
.
local
.
sms
.
send
);
// 发短信验证码
router
.
post
(
'/login/sms/send'
,
captcha
.
requiredAPI
,
login
.
local
.
sms
.
send
);
// 发短信验证码
router
.
post
(
'/login/sms/auth'
,
login
.
local
.
sms
.
auth
);
// 验证短信验证码
router
.
post
(
'/login/sms/checkuser'
,
login
.
local
.
sms
.
checkUser
);
// 短信检查用户是否注册
...
...
public/js/passport/login/index.js
View file @
bc0be2a
...
...
@@ -505,7 +505,15 @@ function sendCaptchaSmsAsync() {
url
:
'/passport/login/sms/send'
,
data
:
{
area
:
getArea
(),
mobile
:
getMoblie
()
mobile
:
getMoblie
(),
verifyCode
:
$
.
trim
(
$imgCaptchaInput
.
val
())
}
}).
then
(
function
(
data
)
{
if
(
data
.
captchaCount
===
false
)
{
errTip
(
$imgCaptchaInput
,
data
.
message
);
ep
.
emit
(
'captcha'
,
false
);
refreshCaptcha
();
return
false
;
}
});
}
...
...
@@ -644,6 +652,8 @@ $smsBtn.on('mousedown', function() {
$imgCaptchaInput
.
off
(
'blur'
);
// 点发送验证码按钮不需要执行图形验证码的blur事件 因此移除
$imgCaptchaInput
.
removeClass
(
'focus'
);
$smsCaptchaInput
.
off
(
'blur'
);
$smsCaptchaInput
.
removeClass
(
'focus'
);
validateAccount
()
.
then
(
function
()
{
...
...
@@ -656,15 +666,16 @@ $smsBtn.on('mousedown', function() {
});
// 短信验证码
$smsCaptchaInput
.
on
(
'blur'
,
function
()
{
function
smsCaptchaInput
()
{
$smsCaptchaInput
.
removeClass
(
'focus'
);
validateCaptchaSms
();
}).
on
(
'focus'
,
function
()
{
}
$smsCaptchaInput
.
on
(
'focus'
,
function
()
{
$smsCaptchaInput
.
addClass
(
'focus'
);
hideTip
(
$smsCaptchaInput
);
$
(
this
).
off
(
'blur'
).
on
(
'blur'
,
smsCaptchaInput
);
});
/** **************************************************登录事件********************************************/
// 登录
function
login
()
{
...
...
Please
register
or
login
to post a comment