-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原先作为sessionId的依据为FromUserName,应考虑到多个商家可能出现用户id重复的问题 #29
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,13 @@ var respond = function (handler) { | |
if (req.sessionStore) { | ||
var storage = req.sessionStore; | ||
var _end = res.end; | ||
var openid = message.FromUserName; | ||
var userOpenid = message.FromUserName; | ||
var serviceOpenid = message.ToUserName; | ||
var _str = serviceOpenid + ":" + userOpenid; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不用hash吧? |
||
var _hash = crypto.createHash("md5"); | ||
_hash.update(_str); | ||
var _hashmsg = hash.digest('hex'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的hash未定义。测试都broken了 |
||
var hashid = _hashmsg.toString(); | ||
res.end = function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
只改这一句就好了 |
||
_end.apply(res, arguments); | ||
if (req.wxsession) { | ||
|
@@ -166,12 +172,12 @@ var respond = function (handler) { | |
res.reply.apply(res, arguments); | ||
}; | ||
|
||
storage.get(openid, function (err, session) { | ||
storage.get(hashid, function (err, session) { | ||
if (!session) { | ||
req.wxsession = new Session(openid, req); | ||
req.wxsession = new Session(hashid, req); | ||
req.wxsession.cookie = req.session.cookie; | ||
} else { | ||
req.wxsession = new Session(openid, req, session); | ||
req.wxsession = new Session(hashid, req, session); | ||
} | ||
done(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缩进也有问题