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
ae0ecfae3fd626d35f05a6fd6488f4b471faf574
1 parent
0fd22ca0
调整登录的代码。
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
apps/passport/controllers/login.js
apps/passport/controllers/login.js
View file @
ae0ecfa
...
...
@@ -269,30 +269,23 @@ const sina = {
* QQ登录
*/
const
qq
=
{
login
:
(
req
,
res
,
next
)
=>
{
req
.
session
=
req
.
session
||
{};
req
.
session
.
authState
=
uuid
.
v4
();
return
passport
.
authenticate
(
'qq'
,
{
state
:
req
.
session
.
authState
})(
req
,
res
,
next
);
login
:
(
req
,
res
)
=>
{
let
authState
=
req
.
session
.
authState
=
uuid
.
v4
();
return
res
.
redirect
(
`
//www.yohobuy.com/passport/autosign/qq?type=yohoblk&state=${authState}`)
},
callback
:
(
req
,
res
,
next
)
=>
{
if
(
req
.
session
&&
req
.
session
.
authState
&&
req
.
session
.
authState
===
req
.
query
.
state
)
{
passport
.
authenticate
(
'qq'
,
(
err
,
user
)
=>
{
if
(
err
)
{
log
.
error
(
`
qq
authenticate
error
:
$
{
JSON
.
stringify
(
err
)}
`
);
return
res
.
redirect
(
loginPageURL
);
}
let
nickname
=
user
.
nickname
;
let
openId
=
user
.
id
;
if
(
req
.
query
.
err
)
{
log
.
error
(
`
qq
authenticate
error
:
$
{
JSON
.
stringify
(
err
)}
`
);
return
res
.
redirect
(
loginPageURL
);
}
_doPassportCallback
(
req
,
res
,
{
openId
:
openId
,
nickname
:
nickname
,
sourceType
:
'qq'
}).
catch
(
next
);
})(
req
,
res
,
next
);
_doPassportCallback
(
req
,
res
,
{
openId
:
req
.
query
.
openid
,
nickname
:
req
.
query
.
nickname
,
sourceType
:
'qq'
}).
catch
(
next
);
}
else
{
return
next
(
new
Error
(
'Auth State Mismatch'
));
}
...
...
Please
register
or
login
to post a comment