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
Plain Diff
Browse Files
Authored by
yyq
9 years ago
Commit
955b8fc485b541e9aa0ea230f62975b20728fe7e
2 parents
636fe5c9
74adadcd
Merge branch 'release/1.0' of git.yoho.cn:fe/yoho-blk into release/1.0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
9 deletions
apps/channel/models/index.js
apps/channel/views/partial/slider.hbs
apps/passport/models/login-service.js
doraemon/middleware/auth.js
doraemon/middleware/user.js
apps/channel/models/index.js
View file @
955b8fc
...
...
@@ -43,12 +43,13 @@ const _getBrandAdFloor = d => {
* @return {Object} 处理之后的数据
*/
const
_getNewArrivals
=
d
=>
{
console
.
log
(
d
);
_
.
forEach
(
d
,
(
data
,
index
)
=>
{
if
(
index
===
0
||
index
===
d
.
length
-
1
)
{
data
.
smallImg
=
true
;
}
if
(
index
%
2
=
==
0
)
{
if
(
index
%
2
!
==
0
)
{
data
.
even
=
true
;
}
});
...
...
apps/channel/views/partial/slider.hbs
View file @
955b8fc
...
...
@@ -4,7 +4,7 @@
{{#
slider
}}
<li
style=
"
{{#if
bgColor
}}
background:
{{
bgColor
}}{{/if}}
"
>
<a
href=
"
{{
url
}}
"
target=
"_blank"
>
<img
class=
"lazy"
data-original=
"
{{
image
src
1
920
645
}}
"
alt=
""
>
<img
class=
"lazy"
data-original=
"
{{
image
src
1
150
570
}}
"
alt=
""
>
</a>
{{#
tips
}}
<div
class=
"slide-tips"
>
...
...
apps/passport/models/login-service.js
View file @
955b8fc
...
...
@@ -9,6 +9,7 @@ const _ = require('lodash');
const
cache
=
global
.
yoho
.
cache
;
const
sign
=
global
.
yoho
.
sign
;
const
config
=
global
.
yoho
.
config
;
const
crypto
=
global
.
yoho
.
crypto
;
const
api
=
require
(
'./login-api'
);
const
UserService
=
require
(
'./user-service'
);
...
...
@@ -37,7 +38,7 @@ const syncUserSession = (uid, req, res) => {
let
user
=
userInfo
.
data
;
if
(
!
_
.
isEmpty
(
user
))
{
let
uidCookie
=
`
{
data
.
profile_name
}::
$
{
user
.
uid
}::
$
{
user
.
username
}
::
$
{
token
}
`
;
let
uidCookie
=
`
$
{
user
.
profile_name
}::
$
{
crypto
.
encryption
(
''
,
user
.
uid
+
''
)
}::
$
{
user
.
username
}
::
$
{
token
}
`
;
req
.
session
.
_TOKEN
=
token
;
req
.
session
.
_LOGIN_UID
=
uid
;
...
...
doraemon/middleware/auth.js
View file @
955b8fc
...
...
@@ -13,8 +13,6 @@ module.exports = (req, res, next) => {
let
refer
=
''
;
if
(
req
.
method
===
'GET'
)
{
refer
=
req
.
getUrl
();
}
else
{
refer
=
req
.
get
(
'Referer'
);
}
...
...
doraemon/middleware/user.js
View file @
955b8fc
...
...
@@ -10,9 +10,6 @@ const LoginService = require('../../apps/passport/models/login-service');
*/
module
.
exports
=
()
=>
{
return
(
req
,
res
,
next
)
=>
{
req
.
getUrl
=
function
()
{
return
req
.
protocol
+
'://'
+
req
.
get
(
'host'
)
+
req
.
originalUrl
;
};
// 从 SESSION 中获取到当前登录用户的 UID
if
(
req
.
session
&&
_
.
isNumber
(
req
.
session
.
_LOGIN_UID
))
{
...
...
@@ -22,6 +19,7 @@ module.exports = () => {
// session 没有读取到的时候,从 cookie 读取 UID
if
(
!
req
.
user
.
uid
&&
req
.
cookies
.
_UID
)
{
req
.
user
.
uid
=
cookie
.
getUid
(
req
);
console
.
log
(
'req.user.uid'
,
req
.
user
.
uid
);
}
// 从 SESSION 中获得 USERNAME
...
...
@@ -49,7 +47,7 @@ module.exports = () => {
return
LoginService
.
syncUserSession
(
result
.
data
.
uid
,
req
,
res
);
}).
then
(()
=>
{
return
res
.
redirect
(
req
.
getUrl
()
);
return
res
.
redirect
(
req
.
originalUrl
);
}).
catch
(
next
);
}
else
{
return
next
();
...
...
Please
register
or
login
to post a comment