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
htoooth
9 years ago
Commit
2a8e780c69dec63c4372ff1511393a04b2699206
1 parent
388fd130
master
...
develop
feature/catch
feature/docker
feature/login-msg
feature/login-ua-ip
feature/removCamel
feature/safe-bug
feature/sessionKey
feature/setting
feature/vip
feature/webpack2
feature/wsl5.3
gray
release/2.0
release/fontBack2.0
调整代码
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
72 additions
and
58 deletions
apps/passport/controllers/bind.js
apps/passport/controllers/reg.js
apps/passport/models/bind-api.js
apps/passport/models/bind-service.js
apps/passport/models/login-api.js
apps/passport/models/login-service.js
apps/passport/models/passport-alipay.js
apps/passport/models/reg-api.js
apps/passport/models/reg-service.js
apps/passport/views/action/back/reset-success.hbs
apps/passport/views/action/reg/success.hbs
apps/passport/controllers/bind.js
View file @
2a8e780
...
...
@@ -9,16 +9,14 @@
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
PassportHelper
=
require
(
'../models/passport-helper'
);
const
BindService
=
require
(
'../models/bind-api'
);
const
loginService
=
require
(
'../models/login-service'
);
const
BindService
=
require
(
'../models/bind-service'
);
const
LoginService
=
require
(
'../models/login-service'
);
const
Sources
=
{
qq
:
'QQ'
,
sina
:
'微博'
,
alipay
:
'支付宝'
,
wechat
:
'微信'
,
renren
:
'人人'
,
douban
:
'豆瓣'
wechat
:
'微信'
};
const
DEFAULT_URL
=
'http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100'
;
...
...
@@ -173,7 +171,7 @@ const bind = {
let
sourceType
=
req
.
body
.
sourceType
;
if
(
mobile
&&
openId
&&
area
&&
sourceType
)
{
BindService
.
bindCheck
(
mobile
,
openId
,
sourceType
,
area
).
then
(
result
=>
{
BindService
.
bindCheck
Async
(
mobile
,
openId
,
sourceType
,
area
).
then
(
result
=>
{
if
(
!
result
||
!
result
.
code
)
{
return
{
code
:
400
,
message
:
''
,
data
:
''
};
}
else
if
(
result
.
code
===
200
&&
result
.
data
.
is_register
===
0
)
{
...
...
@@ -210,7 +208,7 @@ const bind = {
let
mobile
=
req
.
body
.
mobile
;
let
area
=
req
.
body
.
area
;
BindService
.
sendBindMsg
(
area
,
mobile
).
then
(
result
=>
{
BindService
.
sendBindMsg
Async
(
area
,
mobile
).
then
(
result
=>
{
if
(
result
&&
result
.
code
)
{
res
.
json
(
result
);
}
else
{
...
...
@@ -223,7 +221,7 @@ const bind = {
let
area
=
req
.
body
.
area
;
let
code
=
req
.
body
.
code
;
BindService
.
checkBindCode
(
area
,
mobile
,
code
).
then
(
result
=>
{
BindService
.
checkBindCode
Async
(
area
,
mobile
,
code
).
then
(
result
=>
{
if
(
result
&&
result
.
code
)
{
res
.
json
(
result
);
}
else
{
...
...
@@ -238,14 +236,14 @@ const bind = {
let
sourceType
=
_
.
trim
(
req
.
body
.
sourceType
);
let
password
=
_
.
trim
(
req
.
body
.
password
)
||
''
;
BindService
.
bindMobile
(
openId
,
sourceType
,
mobile
,
area
,
password
).
then
(
result
=>
{
BindService
.
bindMobile
Async
(
openId
,
sourceType
,
mobile
,
area
,
password
).
then
(
result
=>
{
if
(
result
&&
result
.
code
)
{
if
(
result
.
code
===
200
&&
result
.
data
&&
result
.
data
.
uid
)
{
let
refer
=
helpers
.
urlFormat
(
'/passport/thirdlogin/bindsuccess'
,
{
sourceType
:
sourceType
+
'_bind'
});
return
l
oginService
.
syncUserSession
(
result
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
L
oginService
.
syncUserSession
(
result
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
{
code
:
200
,
message
:
result
.
message
,
data
:
{
refer
:
refer
}};
});
}
else
{
...
...
@@ -264,14 +262,14 @@ const bind = {
let
areaCode
=
req
.
body
.
areaCode
||
'86'
;
let
sourceType
=
req
.
body
.
sourceType
;
return
BindService
.
relateMobile
(
openId
,
sourceType
,
mobile
,
areaCode
).
then
(
result
=>
{
return
BindService
.
relateMobile
Async
(
openId
,
sourceType
,
mobile
,
areaCode
).
then
(
result
=>
{
if
(
result
&&
result
.
code
)
{
if
(
result
.
code
===
200
&&
result
.
data
&&
result
.
data
.
uid
)
{
let
refer
=
helpers
.
urlFormat
(
'/passport/thirdlogin/relatesuccess'
,
{
sourceType
:
sourceType
+
'_bind'
});
return
l
oginService
.
syncUserSession
(
result
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
L
oginService
.
syncUserSession
(
result
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
{
code
:
200
,
message
:
result
.
message
,
data
:
{
refer
:
refer
}};
});
}
else
{
...
...
apps/passport/controllers/reg.js
View file @
2a8e780
...
...
@@ -5,9 +5,9 @@
const
_
=
require
(
'lodash'
);
const
Promise
=
require
(
'bluebird'
);
const
passportHelper
=
require
(
'../models/passport-helper'
);
const
regService
=
require
(
'../models/reg-api'
);
const
userService
=
require
(
'../models/user-service'
);
const
loginService
=
require
(
'../models/login-service'
);
const
RegService
=
require
(
'../models/reg-service'
);
const
UserService
=
require
(
'../models/user-service'
);
const
LoginService
=
require
(
'../models/login-service'
);
const
config
=
require
(
'../../../config/common'
);
let
helpers
=
global
.
yoho
.
helpers
;
...
...
@@ -100,7 +100,7 @@ let checkMobile = (req, res, next) => {
}
// 判断用户是否存在
return
u
serService
.
findByMobileAsync
(
area
,
mobile
).
then
((
user
)
=>
{
return
U
serService
.
findByMobileAsync
(
area
,
mobile
).
then
((
user
)
=>
{
if
(
!
_
.
isEmpty
(
user
))
{
data
.
message
=
'手机号码已经存在'
;
return
res
.
json
(
data
);
...
...
@@ -156,7 +156,7 @@ let sendBindMsg = (req, res, next) => {
}
/* 向手机发送注册验证码 */
let
result
=
yield
regService
.
sendCodeToMobile
(
area
,
mobile
);
let
result
=
yield
RegService
.
sendCodeToMobileAsync
(
area
,
mobile
);
return
cache
.
set
(
sendCodeKey
,
sendCodeTimes
+
1
,
3600
).
then
(()
=>
{
if
(
result
.
code
)
{
...
...
@@ -182,7 +182,7 @@ let msgCaptcha = (req, res, next) => {
let
mobile
=
req
.
body
.
mobile
;
let
code
=
req
.
body
.
code
;
// 短信验证码
regService
.
validMobileCode
(
area
,
mobile
,
code
).
then
((
result
)
=>
{
RegService
.
validMobileCodeAsync
(
area
,
mobile
,
code
).
then
((
result
)
=>
{
if
(
result
.
code
)
{
return
res
.
json
(
result
);
}
else
{
...
...
@@ -232,7 +232,7 @@ let mobileRegister = (req, res, next) => {
let
mobile
=
req
.
body
.
mobile
;
let
code
=
req
.
body
.
code
;
// 短信验证码
let
password
=
req
.
body
.
password
;
let
result
=
yield
regService
.
validMobileCode
(
area
,
mobile
,
code
);
// 验证注册的标识码是否有效
let
result
=
yield
RegService
.
validMobileCodeAsync
(
area
,
mobile
,
code
);
// 验证注册的标识码是否有效
if
(
!
result
.
code
||
result
.
code
!==
200
)
{
data
.
message
=
'验证码错误'
;
...
...
@@ -240,14 +240,14 @@ let mobileRegister = (req, res, next) => {
}
/* 手机注册: 调用注册接口*/
let
regResult
=
yield
regService
.
regMobile
(
area
,
mobile
,
password
,
cookie
.
getShoppingKey
(
req
));
let
regResult
=
yield
RegService
.
regMobileAsync
(
area
,
mobile
,
password
,
cookie
.
getShoppingKey
(
req
));
if
(
!
regResult
.
code
||
regResult
.
code
!==
200
)
{
data
.
message
=
'注册失败'
;
return
res
.
json
(
data
);
}
return
l
oginService
.
syncUserSession
(
regResult
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
L
oginService
.
syncUserSession
(
regResult
.
data
.
uid
,
req
,
res
).
then
(()
=>
{
return
res
.
json
({
code
:
200
,
message
:
'注册成功'
,
...
...
@@ -272,7 +272,7 @@ let success = (req, res) => {
title
:
'注册成功'
,
passport
:
{
goUrl
:
goUrl
,
goShopp
o
ng
:
goShoppingUrl
,
goShopp
i
ng
:
goShoppingUrl
,
mobile
:
mobile
}
});
...
...
apps/passport/models/bind-api.js
View file @
2a8e780
...
...
@@ -9,7 +9,7 @@
const
api
=
global
.
yoho
.
API
;
const
bindCheck
=
(
mobile
,
openId
,
sourceType
,
area
)
=>
{
const
bindCheck
Async
=
(
mobile
,
openId
,
sourceType
,
area
)
=>
{
let
params
=
{
method
:
'app.passport.signCheck'
,
area
:
area
,
...
...
@@ -21,7 +21,7 @@ const bindCheck = (mobile, openId, sourceType, area) => {
return
api
.
get
(
''
,
params
);
};
const
sendBindMsg
=
(
area
,
mobile
)
=>
{
const
sendBindMsg
Async
=
(
area
,
mobile
)
=>
{
let
params
=
{
method
:
'app.passport.smsbind'
,
mobile
:
mobile
,
...
...
@@ -31,7 +31,7 @@ const sendBindMsg = (area, mobile) => {
return
api
.
get
(
''
,
params
);
};
const
checkBindCode
=
(
area
,
mobile
,
code
)
=>
{
const
checkBindCode
Async
=
(
area
,
mobile
,
code
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.register.validRegCode'
,
mobile
:
mobile
,
...
...
@@ -40,7 +40,7 @@ const checkBindCode = (area, mobile, code) => {
});
};
const
bindMobile
=
(
openId
,
sourceType
,
mobile
,
area
,
password
,
nickname
)
=>
{
const
bindMobile
Async
=
(
openId
,
sourceType
,
mobile
,
area
,
password
,
nickname
)
=>
{
let
params
=
{
method
:
'app.passport.bind'
,
mobile
:
mobile
,
...
...
@@ -60,7 +60,7 @@ const bindMobile = (openId, sourceType, mobile, area, password, nickname) => {
return
api
.
get
(
''
,
params
);
};
const
relateMobile
=
(
openId
,
sourceType
,
mobile
,
area
)
=>
{
const
relateMobile
Async
=
(
openId
,
sourceType
,
mobile
,
area
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.passport.relatedMobile'
,
mobile
:
mobile
,
...
...
@@ -70,7 +70,7 @@ const relateMobile = (openId, sourceType, mobile, area) => {
});
};
const
changeCheck
=
(
mobile
,
area
)
=>
{
const
changeCheck
Async
=
(
mobile
,
area
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.passport.changeCheck'
,
mobile
:
mobile
,
...
...
@@ -78,7 +78,7 @@ const changeCheck = (mobile, area) => {
});
};
const
changeMobile
=
(
uid
,
mobile
,
area
,
code
)
=>
{
const
changeMobile
Async
=
(
uid
,
mobile
,
area
,
code
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.passport.changeMobile'
,
mobile
:
mobile
,
...
...
@@ -89,11 +89,11 @@ const changeMobile = (uid, mobile, area, code) => {
};
module
.
exports
=
{
bindCheck
,
sendBindMsg
,
checkBindCode
,
bindMobile
,
relateMobile
,
changeCheck
,
changeMobile
bindCheckAsync
,
sendBindMsgAsync
,
checkBindCodeAsync
,
bindMobileAsync
,
relateMobileAsync
,
changeCheckAsync
,
changeMobileAsync
};
...
...
apps/passport/models/bind-service.js
0 → 100644
View file @
2a8e780
/**
* Created by TaoHuang on 2016/7/26.
*/
'use strict'
;
const
api
=
require
(
'./bind-api'
);
module
.
exports
=
api
;
...
...
apps/passport/models/login-api.js
View file @
2a8e780
...
...
@@ -6,7 +6,7 @@
const
api
=
global
.
yoho
.
API
;
const
signin
=
(
area
,
profile
,
password
,
shoppingKey
)
=>
{
const
signin
Asnyc
=
(
area
,
profile
,
password
,
shoppingKey
)
=>
{
let
param
=
{
method
:
'app.passport.signin'
,
area
:
area
,
...
...
@@ -21,7 +21,7 @@ const signin = (area, profile, password, shoppingKey) => {
return
api
.
post
(
''
,
param
);
};
const
signinByOtherOpenID
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
)
=>
{
const
signinByOtherOpenID
Async
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
)
=>
{
let
param
=
{
nickname
:
nickname
,
openId
:
openId
,
...
...
@@ -36,7 +36,7 @@ const signinByOtherOpenID = (nickname, openId, sourceType, shoppingKey) => {
return
api
.
get
(
''
,
param
);
};
const
signinByWechat
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
,
unionId
)
=>
{
const
signinByWechat
Async
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
,
unionId
)
=>
{
let
param
=
{
nickname
:
nickname
,
openId
:
openId
,
...
...
@@ -53,7 +53,7 @@ const signinByWechat = (nickname, openId, sourceType, shoppingKey, unionId) => {
};
module
.
exports
=
{
signin
,
signinByOtherOpenID
,
signinByWechat
signinAsnyc
,
signinByOtherOpenIDAsync
,
signinByWechatAsync
};
...
...
apps/passport/models/login-service.js
View file @
2a8e780
...
...
@@ -13,10 +13,10 @@ const config = global.yoho.config;
const
api
=
require
(
'./login-api'
);
const
userService
=
require
(
'./user-service'
);
const
signinByOpenID
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
,
unionId
)
=>
{
const
signinByOpenID
Async
=
(
nickname
,
openId
,
sourceType
,
shoppingKey
,
unionId
)
=>
{
let
signinFunc
=
{
other
:
api
.
signinByOtherOpenID
,
wechat
:
api
.
signinByWechat
other
:
api
.
signinByOtherOpenIDAsync
,
wechat
:
api
.
signinByWechatAsync
};
// PC 的微信登录之前使用了 open_id, 所以需要特别的接口处理
...
...
@@ -73,8 +73,8 @@ const rememberAccount = (accountInfo, req, res) => {
};
module
.
exports
=
{
signin
:
api
.
signin
,
signinByOpenID
,
signinAsync
:
api
.
signinAsync
,
signinByOpenIDAsync
,
syncUserSession
,
rememberAccount
};
...
...
apps/passport/models/passport-alipay.js
View file @
2a8e780
...
...
@@ -48,7 +48,7 @@ function AlipayStrategy(options, verify) {
options
=
options
||
{};
passport
.
Strategy
.
call
(
this
);
this
.
name
=
'alipay'
;
this
.
_verify
=
verif
y
;
this
.
_verify
=
verif
this
.
_options
=
options
;
}
...
...
apps/passport/models/reg-api.js
View file @
2a8e780
...
...
@@ -4,7 +4,7 @@
'use strict'
;
const
api
=
global
.
yoho
.
API
;
let
sendCodeToMobile
=
(
area
,
mobile
)
=>
{
let
sendCodeToMobile
Async
=
(
area
,
mobile
)
=>
{
let
params
=
{
method
:
'app.register.sendRegCodeToMobile'
,
area
:
area
,
...
...
@@ -14,7 +14,7 @@ let sendCodeToMobile = (area, mobile) => {
return
api
.
post
(
''
,
params
);
};
let
validMobileCode
=
(
area
,
mobile
,
code
)
=>
{
let
validMobileCode
Async
=
(
area
,
mobile
,
code
)
=>
{
let
params
=
{
method
:
'app.register.validRegCode'
,
area
:
area
,
...
...
@@ -25,7 +25,7 @@ let validMobileCode = (area, mobile, code) => {
return
api
.
post
(
''
,
params
);
};
let
regMobile
=
(
area
,
mobile
,
password
,
shoppingKey
)
=>
{
let
regMobile
Async
=
(
area
,
mobile
,
password
,
shoppingKey
)
=>
{
let
params
=
{
method
:
'app.passport.register'
,
area
:
area
,
...
...
@@ -41,7 +41,7 @@ let regMobile = (area, mobile, password, shoppingKey)=> {
};
module
.
exports
=
{
sendCodeToMobile
,
validMobileCode
,
regMobile
sendCodeToMobileAsync
,
validMobileCodeAsync
,
regMobileAsync
};
...
...
apps/passport/models/reg-service.js
0 → 100644
View file @
2a8e780
/**
* Created by TaoHuang on 2016/7/26.
*/
'use strict'
;
const
api
=
require
(
'./reg-api'
);
module
.
exports
=
api
;
...
...
apps/passport/views/action/back/reset-success.hbs
View file @
2a8e780
...
...
@@ -52,9 +52,7 @@
var
count
=
5
,
countDown
=
document
.
getElementById
(
'count-down'
);
console
.
log
(
countDown
);
var
timer
=
setInterval
(
function
()
{
setInterval
(
function
()
{
if
(
count
>
1
)
{
count
--
;
countDown
.
innerHTML
=
count
;
...
...
apps/passport/views/action/reg/success.hbs
View file @
2a8e780
...
...
@@ -9,7 +9,7 @@
<div>
尊敬的
{{
mobile
}}
,恭喜您已经成为YOHO!BLK会员!即刻您可以开启时尚购物之旅!
</div>
<a
class=
"btn btn-fixed-height success-btn"
href=
"
{{
goShopp
o
ng
}}
"
data-url=
"
{{
goUrl
}}
"
>
开始购物
</a>
<a
class=
"btn btn-fixed-height success-btn"
href=
"
{{
goShopp
i
ng
}}
"
data-url=
"
{{
goUrl
}}
"
>
开始购物
</a>
</div>
{{/
passport
}}
</div>
...
...
Please
register
or
login
to post a comment