Incognito check

This commit is contained in:
Dan Seripap 2016-01-08 15:57:31 -05:00
parent 6c88638829
commit 28ea129c10
2 changed files with 14 additions and 4 deletions

View File

@ -24,7 +24,7 @@ const sessionMiddleware = session({
saveUninitialized: true saveUninitialized: true
}); });
var rooms = []; let rooms = [];
io.use(function(socket, next) { io.use(function(socket, next) {
sessionMiddleware(socket.request, socket.request.res, next); sessionMiddleware(socket.request, socket.request.res, next);
@ -44,9 +44,7 @@ function generateNewRoom(req, res, id) {
console.log('generating new room'); console.log('generating new room');
room.on('empty', function() { room.on('empty', function() {
console.log('room empty', room._id);
rooms = _.without(rooms, _.findWhere(rooms, {_id: room._id})); rooms = _.without(rooms, _.findWhere(rooms, {_id: room._id}));
}); });
return res.redirect(`/${id}`); return res.redirect(`/${id}`);
@ -64,7 +62,7 @@ app.get('/loaderio-6f94612a3fa71ff98b23eecfcca2de6c.html', (req, res) => {
app.get('/:roomId', (req, res) => { app.get('/:roomId', (req, res) => {
const roomId = req.params.roomId || false; const roomId = req.params.roomId || false;
let roomExists = _.findWhere(rooms, {_id: roomId}) ? true : false; let roomExists = _.findWhere(rooms, {_id: roomId}) || false;
if (roomExists) { if (roomExists) {
return res.render('index', {username: shortid.generate()}); return res.render('index', {username: shortid.generate()});

View File

@ -1,3 +1,5 @@
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
$(function() { $(function() {
var FADE_TIME = 150; // ms var FADE_TIME = 150; // ms
var TYPING_TIMER_LENGTH = 400; // ms var TYPING_TIMER_LENGTH = 400; // ms
@ -41,6 +43,16 @@ $(function() {
// Sets the client's username // Sets the client's username
function setUsername () { function setUsername () {
username = window.username; username = window.username;
// warn not incognitor
if (!fs) {
console.log('no fs');
} else {
fs(window.TEMPORARY,
100,
log.bind(log, "!!WARNING!! : Your browser is not in incognito mode! : !!WARNING!!"),
log.bind(log, "Your browser is in incognito mode."));
}
// If the username is valid // If the username is valid
if (username) { if (username) {
$chatPage.show(); $chatPage.show();