Delete just for Khai
This commit is contained in:
parent
0533dae04a
commit
bc6aa6dd28
11 changed files with 0 additions and 2369 deletions
|
|
@ -1,28 +0,0 @@
|
|||
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