Last commit ?

This commit is contained in:
NyxiumYuuki 2021-06-06 11:40:14 +02:00
parent 75060a0997
commit 34a5f703ea
9 changed files with 61 additions and 26 deletions

View file

@ -10,7 +10,7 @@ app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
const cors = require('cors');
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
const mongoConnect = require('./mongodbConnect');

View file

@ -7,14 +7,20 @@ function getSession (req, callback) {
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);
console.log("body ; getSession auth message :",body);
if(typeof body !== 'undefined'){
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);
}
}
}
else{
return callback('Error');
}
});
}
return callback(undefined);

View file

@ -11,7 +11,7 @@ const app = express();
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: "http://127.0.0.1:4200",
origin: "http://localhost:4200",
methods: ["GET", "POST"],
credentials: true
}
@ -19,7 +19,7 @@ const io = new Server(server, {
const port = process.env.PORT || 3001;
app.use(bodyParser.json());
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
app.use(cookieParser());
@ -114,6 +114,6 @@ io.on('connection',socket => {
});
});
server.listen(port, '0.0.0.0',() => {
server.listen(port,'0.0.0.0', () => {
console.log (`listening on port ${port}`);
});

View file

@ -7,14 +7,20 @@ function getSession (req, callback) {
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);
console.log("body ; getSession auth private :",body);
if(typeof body !== 'undefined'){
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);
}
}
}
else{
return callback('Error');
}
});
}
return callback(undefined);

View file

@ -6,7 +6,7 @@ const { Server } = require("socket.io");
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: "http://127.0.0.1:4200",
origin: "http://localhost:4200",
methods: ["GET", "POST"],
credentials: true
}
@ -20,7 +20,7 @@ const cookieParser = require('cookie-parser');
app.use(cookieParser());
const cors = require('cors');
app.use(cors({origin: 'http://127.0.0.1:4200', credentials: true}));
app.use(cors({origin: 'http://localhost:4200', credentials: true}));
const auth = require("./auth");