Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
ccbikai(👎🏻🍜)
8 years ago
Commit
ac256c3457008b3ce6ed5658f7e572e23bf58791
2 parents
c74c6758
de25a4bd
Merge remote-tracking branch 'origin/feature/geetest' into gray
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
66 deletions
apps/passport/controllers/geetest.js
apps/passport/controllers/login.js
public/js/passport/login/international.js
apps/passport/controllers/geetest.js
View file @
ac256c3
'use strict'
;
const
_
=
require
(
'lodash'
);
const
Geetest
=
require
(
'geetest'
);
const
logger
=
global
.
yoho
.
logger
;
const
captcha
=
new
Geetest
({
geetest_id
:
'bce95d796bc3058615fdf2ec2c0aef29'
,
...
...
@@ -50,8 +51,10 @@ const geetest = {
seccode
}).
then
(
function
(
success
)
{
if
(
success
)
{
logger
.
info
(
'geetest success'
);
return
next
();
}
logger
.
info
(
'geetest faild'
);
return
res
.
send
(
errRes
);
});
}
...
...
apps/passport/controllers/login.js
View file @
ac256c3
...
...
@@ -144,6 +144,16 @@ const local = {
});
},
international
:
(
req
,
res
)
=>
{
// 是否关闭账号登录
let
closePassword
=
_
.
get
(
req
.
app
.
locals
.
wap
,
'close.passwordLogin'
,
false
);
if
(
closePassword
)
{
return
res
.
redirect
(
`
/
signin
.
html
?
refer
=
$
{
req
.
query
.
refer
||
''
}
`
);
}
if
(
req
.
session
.
captchaValidCount
==
null
)
{
// eslint-disable-line
req
.
session
.
captchaValidCount
=
5
;
}
// 先清除cookie
// res.clearCookie('LE' + md5('_LOGIN_EXPIRE'), {
// domain: 'yohobuy.com'
...
...
public/js/passport/login/international.js
View file @
ac256c3
...
...
@@ -4,7 +4,7 @@
* @date: 2015/10/8
*/
var
$
=
require
(
'yoho-jquery'
);
var
ImgCheck
=
require
(
'plugin/img-check
'
);
var
Validate
=
require
(
'plugin/validata
'
);
var
$phoneNum
=
$
(
'#phone-num'
),
$countrySelect
=
$
(
'#country-select'
),
...
...
@@ -23,7 +23,7 @@ var tip = require('plugin/tip');
var
trim
=
$
.
trim
;
var
showErrTip
=
tip
.
show
;
var
imgCheck
=
new
ImgCheck
(
$captcha
,
{
var
validate
=
new
Validate
(
$captcha
,
{
useREM
:
{
rootFontSize
:
40
,
picWidth
:
150
...
...
@@ -31,7 +31,7 @@ var imgCheck = new ImgCheck($captcha, {
});
if
(
$captcha
.
data
(
'init'
)
!=
null
)
{
//eslint-disable-line
imgCheck
.
init
();
validate
.
init
();
}
...
...
@@ -85,82 +85,68 @@ $countrySelect.change(function() {
$loginBtn
.
on
(
'touchstart'
,
function
()
{
var
pn
=
trim
(
$phoneNum
.
val
()),
areaCode
=
$countrySelect
.
val
(),
pwd
=
trim
(
$pwd
.
val
()),
captcha
=
null
;
pwd
=
trim
(
$pwd
.
val
());
if
(
$loginBtn
.
hasClass
(
'disable'
))
{
return
;
}
if
(
imgCheck
.
atWorking
)
{
captcha
=
imgCheck
.
getResults
();
if
(
captcha
===
'0000'
)
{
return
tip
.
show
(
' 请将图片旋转到正确方向'
);
}
}
if
((
api
.
phoneRegx
[
areaCode
].
test
(
pn
)
||
areaCode
!==
'+86'
)
&&
api
.
pwdValidate
(
pwd
))
{
$loginBtn
.
text
(
'正在登录...'
).
addClass
(
'disable'
);
let
validResult
=
validate
.
getResults
(
);
if
((
api
.
phoneRegx
[
areaCode
].
test
(
pn
)
||
areaCode
!==
'+86'
)
&&
api
.
pwdValidate
(
pwd
))
{
let
data
=
{
areaCode
:
areaCode
.
replace
(
'+'
,
''
),
account
:
pn
,
password
:
pwd
};
if
(
imgCheck
.
atWorking
)
{
$
.
extend
(
data
,
{
captcha
});
if
(
typeof
validResult
===
'string'
)
{
if
(
validResult
===
'0000'
)
{
return
tip
.
show
(
' 请将图片旋转到正确方向'
);
}
validResult
=
Promise
.
resolve
({
captcha
:
validResult
});
}
validResult
.
then
((
captcha
)
=>
{
$loginBtn
.
text
(
'正在登录...'
).
addClass
(
'disable'
);
let
data
=
{
areaCode
:
areaCode
.
replace
(
'+'
,
''
),
account
:
pn
,
password
:
pwd
};
if
(
validate
.
atWorking
)
{
$
.
extend
(
data
,
captcha
);
}
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/login/auth'
,
data
,
success
:
function
(
data
)
{
var
res
,
time
;
if
(
data
.
code
===
200
)
{
res
=
data
.
data
;
showErrTip
(
'登录成功'
);
$
.
ajax
({
url
:
res
.
session
,
dataType
:
'jsonp'
,
success
:
function
()
{
clearTimeout
(
time
);
// Cookie写入成功后,1s后跳转页面
setTimeout
(
function
()
{
location
.
href
=
res
.
href
;
},
1000
);
$
.
ajax
({
type
:
'POST'
,
url
:
'/passport/login/auth'
,
data
,
success
:
function
(
data
)
{
var
res
;
if
(
data
.
code
===
200
)
{
res
=
data
.
data
;
showErrTip
(
'登录成功'
);
// 3秒后强制跳转
setTimeout
(
function
()
{
location
.
href
=
res
.
href
;
},
1500
);
$loginBtn
.
text
(
'登录成功'
).
off
();
showErrTip
(
'登录成功'
);
}
else
{
if
(
data
.
captchaShow
)
{
validate
.
atWorking
?
((
data
.
changeCaptcha
||
validate
.
type
===
2
)
&&
validate
.
refresh
())
:
validate
.
init
();
}
});
// 3秒后强制跳转
time
=
setTimeout
(
function
()
{
location
.
href
=
res
.
href
;
},
3000
);
$loginBtn
.
text
(
'登录成功'
).
off
();
showErrTip
(
'登录成功'
);
}
else
{
if
(
data
.
captchaShow
)
{
imgCheck
.
atWorking
?
imgCheck
.
refresh
()
:
imgCheck
.
init
();
showErrTip
(
data
.
message
);
resetForm
();
}
},
error
:
function
()
{
showErrTip
(
'网络断开连接啦~'
);
$loginBtn
.
text
(
'登录'
);
showErrTip
(
data
.
message
);
resetForm
();
validate
.
atWorking
&&
validate
.
refresh
();
}
},
error
:
function
()
{
showErrTip
(
'网络断开连接啦~'
);
$loginBtn
.
text
(
'登录'
);
imgCheck
.
atWorking
&&
imgCheck
.
refresh
();
}
});
});
}
else
{
showErrTip
(
'账号或密码有错误,请重新输入'
);
...
...
Please
register
or
login
to post a comment