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
yyq
7 years ago
Commit
74c0e5bdd2590b0012f2a6ba0e3225b9533b6fae
2 parents
9ada6060
7470aa53
Merge remote-tracking branch 'origin/master' into hotfix/userAccount
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
93 deletions
apps/3party/controllers/sitemap.js
apps/home/models/user-api.js
apps/home/models/user-service.js
apps/home/views/partial/home/edit/basicinfo.hbs
docker.sh
doraemon/middleware/error-handler.js
doraemon/middleware/limiter/index.js
doraemon/middleware/limiter/rules/ip-white-list.js
doraemon/views/partial/footer.hbs
apps/3party/controllers/sitemap.js
View file @
74c0e5b
...
...
@@ -7,7 +7,7 @@ const sm = require('sitemap');
const
staticUrls
=
require
(
'../../../config/staticUrls'
);
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
const
siteMapService
=
require
(
'../models/site-map-service'
);
const
cache
=
global
.
yoho
.
cache
;
const
cache
=
global
.
yoho
.
cache
.
master
;
const
getStaticUrls
=
(
currentStatics
)
=>
{
let
urls
=
[];
...
...
apps/home/models/user-api.js
View file @
74c0e5b
...
...
@@ -86,14 +86,13 @@ module.exports = class extends global.yoho.BaseModel {
editUserInfo
(
userInfo
)
{
let
data
=
{
method
:
'app.passport.modify
Base
'
,
method
:
'app.passport.modify
UserInfo
'
,
uid
:
userInfo
.
uid
,
nick_name
:
userInfo
.
nickname
,
username
:
userInfo
.
username
,
gender
:
userInfo
.
gender
,
profession
:
userInfo
.
profession
,
income
:
userInfo
.
income
,
birthday
:
userInfo
.
birthday
income
:
userInfo
.
income
};
return
this
.
get
({
...
...
apps/home/models/user-service.js
View file @
74c0e5b
...
...
@@ -291,10 +291,6 @@ module.exports = class extends global.yoho.BaseModel {
let
gender
,
genderArr
,
birthday
,
birthdayJson
,
yearArr
,
monthArr
,
dayArr
,
profession
,
professionArr
,
income
,
...
...
@@ -333,11 +329,6 @@ module.exports = class extends global.yoho.BaseModel {
}
}
birthdayJson
=
that
.
getBirthday
(
birthday
);
yearArr
=
birthdayJson
.
yearArr
;
monthArr
=
birthdayJson
.
monthArr
;
dayArr
=
birthdayJson
.
dayArr
;
finalResult
.
userPersonalInfo
=
{
subTitle
:
'会员信息'
,
certified
:
parseInt
(
userInfo
.
vip_info
.
is_student
,
10
)
===
1
,
...
...
@@ -372,24 +363,8 @@ module.exports = class extends global.yoho.BaseModel {
birthday
:
{
labelText
:
'生日:'
,
key
:
'birthday'
,
tips
:
''
,
selects
:
[
{
key
:
'year'
,
options
:
yearArr
,
unit
:
'年'
},
{
key
:
'month'
,
options
:
monthArr
,
unit
:
'月'
},
{
key
:
'day'
,
options
:
dayArr
,
unit
:
'日'
}
]
tips
:
'生日信息仅可修改一次,如需修改,请至最新版app进行修改。'
,
value
:
birthday
},
profession
:
{
labelText
:
'职业:'
,
...
...
@@ -613,12 +588,11 @@ module.exports = class extends global.yoho.BaseModel {
nickname
:
_
.
trim
(
req
.
body
.
nickname
),
username
:
_
.
trim
(
req
.
body
.
username
),
gender
:
req
.
body
.
gender
||
3
,
birthday
:
req
.
body
.
year
===
''
?
''
:
that
.
formatDate
(
req
.
body
.
year
,
req
.
body
.
month
,
req
.
body
.
day
),
profession
:
req
.
body
.
profession
||
0
,
income
:
req
.
body
.
income
||
0
};
if
(
!
userInfo
.
nickname
||
!
userInfo
.
username
||
userInfo
.
birthday
===
''
)
{
if
(
!
userInfo
.
nickname
||
!
userInfo
.
username
)
{
respData
=
Promise
.
resolve
({
code
:
400
,
message
:
'缺失必填项'
,
...
...
apps/home/views/partial/home/edit/basicinfo.hbs
View file @
74c0e5b
...
...
@@ -34,13 +34,7 @@
{{#
birthday
}}
<div
class=
"form-group"
>
<label>
{{
labelText
}}
</label>
{{#
each
selects
}}
<select
name=
"
{{
key
}}
"
id=
"
{{
key
}}
"
>
{{#
each
options
}}
<option
value=
"
{{
value
}}
"
{{#
isChecked
}}
selected
{{/
isChecked
}}
>
{{
text
}}
</option>
{{/
each
}}
</select>
{{
unit
}}
{{/
each
}}
<span
class=
"plain"
>
{{
value
}}
</span>
<span
class=
"tips-p"
id=
"
{{
key
}}
-tip"
>
{{
tips
}}
</span>
</div>
{{/
birthday
}}
...
...
docker.sh
View file @
74c0e5b
...
...
@@ -3,37 +3,13 @@ wordir=$2
cd
$wordir
rm -rf yohobuy-node.tar.gz
if
[[
$1
==
"yoho-gray"
]]
then
yarn --production
=
false
else
yarn
fi
if
[[
$1
==
"yoho-gray"
]]
then
rm -rf public/dist
yarn build
if
[[
$?
==
1
]]
then
echo
"build failed"
exit
1
fi
yarn yo-cli upload -f
if
[[
$?
==
1
]]
then
echo
"file upload failed"
exit
1
fi
rm -rf public/dist
fi
yarn
if
[[
$1
==
"test1"
]]
||
[[
$1
==
"test2"
]]
||
[[
$1
==
"test3"
]]
then
yarn build
fi
node-prune
tar -czf yohobuy-node.tar.gz
*
...
...
doraemon/middleware/error-handler.js
View file @
74c0e5b
...
...
@@ -11,6 +11,7 @@ const config = global.yoho.config;
const
hostname
=
require
(
'os'
).
hostname
();
const
routeEncode
=
require
(
'./route-encode'
);
const
pathWhiteList
=
require
(
'./limiter/rules/path-white-list'
);
const
ipWhiteList
=
require
(
'./limiter/rules/ip-white-list'
);
const
_
=
require
(
'lodash'
);
const
limiterIpTime
=
3600
;
...
...
@@ -104,7 +105,7 @@ exports.serverError = () => {
if
(
err
.
code
===
9999991
||
err
.
code
===
9999992
)
{
let
remoteIp
=
req
.
yoho
.
clientIp
;
if
(
!
_
.
includes
(
pathWhiteList
(),
req
.
path
))
{
if
(
!
_
.
includes
(
pathWhiteList
(),
req
.
path
)
&&
!
(
await
ipWhiteList
(
remoteIp
))
)
{
const
isHuman
=
await
cache
.
getAsync
(
`
$
{
config
.
app
}:
limiter
:
api
:
ishuman
:
$
{
remoteIp
}
`
);
if
(
!
isHuman
)
{
...
...
doraemon/middleware/limiter/index.js
View file @
74c0e5b
...
...
@@ -15,25 +15,6 @@ const captchaPolicy = require('./policies/captcha');
// const reporterPolicy = require('./policies/reporter');
const
IP_WHITE_LIST
=
[
'106.38.38.146'
,
// 北京办公区域
'106.38.38.147'
,
// 北京办公区域
'106.39.86.227'
,
// 北京办公区域
'218.94.75.58'
,
// 南京办公区域
'218.94.75.50'
,
// 南京办公区域
'218.94.77.166'
,
// 南京办公区域
// '222.73.196.18', // B站合作方单击次数快加白名单
'123.206.73.107'
,
// 腾讯云出口IP
'139.199.35.21'
,
// 腾讯云出口IP
'139.199.29.44'
,
// 腾讯云出口IP
'123.206.21.19'
// 腾讯云出口IP
];
const
IP_WHITE_SEGMENT
=
[
'10.66.'
,
// 内网IP段
'192.168.'
// 内网IP段
];
const
limiter
=
(
rule
,
policy
,
context
)
=>
{
return
rule
(
context
,
policy
);
...
...
@@ -42,15 +23,12 @@ const limiter = (rule, policy, context) => {
// 排除条件:ip白名单/路径白名单/异步请求/登录用户
const
_excluded
=
(
req
)
=>
{
let
remoteIp
=
req
.
yoho
.
clientIp
||
''
;
let
remoteIpSegment
=
`
$
{
remoteIp
.
split
(
'.'
).
slice
(
0
,
2
).
join
(
'.'
)}.
`
;
return
co
(
function
*
()
{
let
atWhiteList
=
yield
ipWhiteList
(
remoteIp
);
let
at
IP
WhiteList
=
yield
ipWhiteList
(
remoteIp
);
return
Boolean
(
atWhiteList
||
_
.
includes
(
IP_WHITE_LIST
,
remoteIp
)
||
_
.
includes
(
IP_WHITE_SEGMENT
,
remoteIpSegment
)
||
atIPWhiteList
||
_
.
includes
(
pathWhiteList
(),
req
.
path
)
||
req
.
xhr
||
!
_
.
isEmpty
(
_
.
get
(
req
,
'user.uid'
))
...
...
doraemon/middleware/limiter/rules/ip-white-list.js
View file @
74c0e5b
const
_
=
require
(
'lodash'
);
const
co
=
Promise
.
coroutine
;
const
logger
=
global
.
yoho
.
logger
;
const
cache
=
global
.
yoho
.
cache
.
master
;
const
WHITE_LIST_KEY
=
'whitelist:ip:'
;
const
IP_WHITE_LIST
=
[
'106.38.38.146'
,
// 北京办公区域
'106.38.38.147'
,
// 北京办公区域
'106.39.86.227'
,
// 北京办公区域
'218.94.75.58'
,
// 南京办公区域
'218.94.75.50'
,
// 南京办公区域
'218.94.77.166'
,
// 南京办公区域
// '222.73.196.18', // B站合作方单击次数快加白名单
'123.206.73.107'
,
// 腾讯云出口IP
'139.199.35.21'
,
// 腾讯云出口IP
'139.199.29.44'
,
// 腾讯云出口IP
'123.206.21.19'
// 腾讯云出口IP
];
const
IP_WHITE_SEGMENT
=
[
'10.66.'
,
// 内网IP段
'192.168.'
// 内网IP段
];
module
.
exports
=
(
remoteIp
)
=>
{
let
key
=
`
$
{
WHITE_LIST_KEY
}
$
{
remoteIp
}
`
;
let
remoteIpSegment
=
`
$
{
remoteIp
.
split
(
'.'
).
slice
(
0
,
2
).
join
(
'.'
)}.
`
;
return
co
(
function
*
()
{
if
(
_
.
includes
(
IP_WHITE_LIST
,
remoteIp
)
||
_
.
includes
(
IP_WHITE_SEGMENT
,
remoteIpSegment
))
{
return
true
;
}
let
result
=
Boolean
(
yield
cache
.
getAsync
(
key
));
logger
.
debug
(
key
,
result
);
return
result
;
})();
})().
catch
(
e
=>
{
console
.
error
(
e
);
return
false
;
});
};
...
...
doraemon/views/partial/footer.hbs
View file @
74c0e5b
...
...
@@ -220,7 +220,7 @@
<div
class=
"link-section left"
>
<ul
class=
"clearfix"
>
{{#
footerLinks
}}
<li><a
href=
"
{{
link
}}
"
target=
"_blank"
rel=
"nofollow"
>
{{
name
}}
</a></li>
<li><a
href=
"
{{
link
}}
"
target=
"_blank"
>
{{
name
}}
</a></li>
{{/
footerLinks
}}
</ul>
</div>
...
...
Please
register
or
login
to post a comment