There is a signIn/signUp system in my webApp and I use the socket.emit
event for the authentication flow.
The logic is:
client clicks a signIn button, then his/her userInfo will be emit
to the server-->the server receive the request, and send back the instruction after authentication via another emit
---->upon receiving the instruction, the client change the DOM,disappearing login form, displaying content etc..
However, if client's userInfo is not sent through emit
event but via HTTP get
request. I don't know how to change the specific clients DOM to finish the logic flow.
app.get('/callback', function (req, res, next) {
var code = req.query.code;
client.getAccessToken(code, function (err, result) {
var openid = result.data.openid;
client.getUser(openid, function (err, result) {
var userInfo = result; //this is the userInfo
db.user.insert({username:userInfo.name,password:userInfo.password}) //I register the client here, but it is not reflected in the client's page
res.redirect(/) // redirect the client to the homepage,but I actually want to change the client's DOM
// can I send something from here like socket.emit("successful",{status:"succcessful"}) to the specific client?
});
});
});
via Wei Zheng
No comments:
Post a Comment