Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
590a28abcb7541c5bee05fb5a74c28bac751504a
2 parents
103cd44d
47f24f98
Merge branch 'feature/login-add-captcha'
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
13 deletions
apps/passport/auth.js
apps/passport/router.js
apps/passport/views/action/login/index.hbs
package.json
public/js/passport/login/index.js
apps/passport/auth.js
View file @
590a28a
...
...
@@ -50,12 +50,6 @@ passport.use('local', new LocalStrategy({
return
done
({
message
:
'登录参数错误'
},
null
);
}
let
verifyCode
=
req
.
body
.
captcha
;
if
(
verifyCode
&&
verifyCode
!==
req
.
session
.
captcha
)
{
return
done
({
message
:
'验证码不正确或验证码过期'
,
needCaptcha
:
true
},
null
);
}
let
shoppingKey
=
cookie
.
getShoppingKey
(
req
);
let
account
=
req
.
body
.
account
;
...
...
apps/passport/router.js
View file @
590a28a
...
...
@@ -35,7 +35,16 @@ router.post('/passport/login/qrcode/refresh', login.local.qrcode.refresh);
router
.
post
(
'/passport/login/qrcode/check'
,
login
.
local
.
qrcode
.
check
);
// 验证二维码的状态
router
.
get
(
'/passport/login'
,
login
.
common
.
beforeLogin
,
login
.
local
.
loginPage
);
router
.
post
(
'/passport/login/auth'
,
login
.
local
.
login
);
router
.
post
(
'/passport/login/auth'
,
(
req
,
res
,
next
)
=>
{
if
(
req
.
body
.
loginType
===
'password'
)
{
return
captcha
.
requiredAPI
(
req
,
res
,
next
);
}
else
{
return
next
();
}
},
login
.
local
.
login
);
router
.
get
(
'/passport/logout'
,
login
.
local
.
logout
);
// 微信登录
...
...
apps/passport/views/action/login/index.hbs
View file @
590a28a
...
...
@@ -55,7 +55,7 @@
</span>
</li>
<li
class=
"clearfix captcha-wrap
hide
"
>
<li
class=
"clearfix captcha-wrap"
>
</li>
<li
class=
"relative clearfix sms-login hide"
>
...
...
package.json
View file @
590a28a
{
"name"
:
"yohobuy-node"
,
"version"
:
"5.4.1
7
"
,
"version"
:
"5.4.1
8
"
,
"private"
:
true
,
"description"
:
"A New Yohobuy Project With Express"
,
"repository"
:
{
...
...
public/js/passport/login/index.js
View file @
590a28a
...
...
@@ -55,7 +55,7 @@ var $accountInput1 = $('#account1'),
// 图像验证码
$captchaImgWrapper
=
$
(
'.captcha-wrap'
),
captchaImg
=
new
Captcha
(
'.captcha-wrap'
).
init
(),
$showCaptchaImg
=
fals
e
,
$showCaptchaImg
=
tru
e
,
getCaptchaImgVal
=
function
()
{
return
captchaImg
.
getResults
();
},
...
...
@@ -250,6 +250,8 @@ var tpl = function(text) {
].
join
(
''
);
};
require
(
'../../common/promise'
);
// 切换登录方式
accountChangeEvent
.
add
(
function
(
type
)
{
currentLogin
=
AccountLoginData
[
type
];
...
...
@@ -278,7 +280,10 @@ accountChangeEvent.add(function(type) {
if
(
type
===
AccountLoginData
.
PasswordLogin
.
name
)
{
if
(
$showCaptchaImg
)
{
$captchaImgWrapper
.
removeClass
(
'hide'
);
captchaImg
.
refresh
();
$
.
sleep
(
500
).
then
(
function
()
{
captchaImg
.
refresh
();
});
}
}
...
...
@@ -648,7 +653,9 @@ function validateSmsCaptchaImg() {
}
function
refreshSmsCaptchaImg
()
{
smsCaptchaImg
.
refresh
();
$
.
sleep
(
1000
).
then
(
function
()
{
smsCaptchaImg
.
refresh
();
});
}
/** ************************************************************************/
...
...
@@ -848,7 +855,7 @@ function loginAsync() {
areaCode
:
getAreaCodeVal
(),
account
:
currentLogin
.
getAccountVal
(),
password
:
currentLogin
.
creditableToken
(),
captcha
:
currentLogin
.
type
()
===
'password'
?
getCaptchaImgVal
()
:
''
,
verifyCode
:
currentLogin
.
type
()
===
'password'
?
getCaptchaImgVal
()
:
''
,
isRemember
:
getRememberMeVal
(),
loginType
:
currentLogin
.
type
()
}
...
...
Please
register
or
login
to post a comment