send existing cookie on join call

This commit is contained in:
AlecM33
2022-01-25 18:05:35 -05:00
parent 14e158c0b4
commit 2c9e7c14f8
5 changed files with 27 additions and 14 deletions

View File

@@ -254,7 +254,11 @@ class GameManager {
}
};
joinGame = (game, name) => {
joinGame = (game, name, cookie) => {
const matchingPerson = findPersonByField(game, 'cookie', cookie);
if (matchingPerson) {
return Promise.resolve(matchingPerson.cookie);
}
if (isNameTaken(game, name)) {
return Promise.reject(400);
}

View File

@@ -3,7 +3,6 @@ const http = require('http');
const https = require('https');
const path = require('path');
const fs = require('fs');
const secure = require('express-force-https');
const ServerBootstrapper = {
processCLIArgs: () => {
@@ -56,8 +55,15 @@ const ServerBootstrapper = {
}
} else {
logger.warn('starting main in PRODUCTION mode. This should not be used for local development.');
app.use(secure);
main = http.createServer(app);
app.use(function(req,res,next) {
const schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (!req.path.includes('/_ah/start') && req.headers.host.indexOf('localhost')<0 && schema!=='https') {
res.redirect('https://' + req.headers.host + req.url);
} else {
next();
}
});
}
return main;