private room but socketio not ready
This commit is contained in:
parent
c652958324
commit
36e6596c78
11 changed files with 5019 additions and 0 deletions
28
backend/service-privateroom/auth.js
Normal file
28
backend/service-privateroom/auth.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const request = require('request');
|
||||
|
||||
function getSession (req, callback) {
|
||||
if(typeof req.headers.cookie !== 'undefined'){
|
||||
request.post({
|
||||
headers: {'content-type' : 'application/x-www-form-urlencoded'},
|
||||
url: 'http://127.0.0.1:3000/verify:token',
|
||||
body: 'sessionid='+req.headers.cookie.replace('SESSIONID=','')
|
||||
},function (error, response, body) {
|
||||
const bodyJson = JSON.parse(body);
|
||||
if (bodyJson && bodyJson.status && bodyJson.data) {
|
||||
if (bodyJson.status === 'ok') {
|
||||
return callback(bodyJson.data.token);
|
||||
} else {
|
||||
return callback(bodyJson.data.reason);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return callback(undefined);
|
||||
}
|
||||
module.exports.getSession = getSession;
|
||||
|
||||
function getUsername(session) {
|
||||
if (typeof session === 'undefined' || typeof session.username === 'undefined') return -1;
|
||||
return session.username;
|
||||
}
|
||||
module.exports.getUsername = getUsername;
|
||||
Reference in a new issue