Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some advances. TODO: test board.js, and then game.js, and then implem…
…ent room.js
- Loading branch information
Benjamin Auder
committed
Jan 12, 2019
1 parent
2305d34
commit fd08ab2
Showing
17 changed files
with
89 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
//TODO: at least this model (maybe MoveModel ?!) | ||
//TODO: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
tell opponent that I got the move, for him to start timer (and lose...) | ||
board2, board3, board4 | ||
VariantRules2, 3 et 4 aussi | ||
fetch challenges and corr games from server at startup (room) | ||
but forbid anonymous to start corr games or accept challenges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
var Access = {}; | ||
|
||
// Prevent access to "users pages" | ||
Access.logged = function(req, res, next) | ||
module.exports = | ||
{ | ||
if (req.userId == 0) | ||
return res.redirect("/"); | ||
next(); | ||
}; | ||
// Prevent access to "users pages" | ||
logged: function(req, res, next) { | ||
if (req.userId == 0) | ||
return res.redirect("/"); | ||
next(); | ||
}, | ||
|
||
// Prevent access to "anonymous pages" | ||
Access.unlogged = function(req, res, next) | ||
{ | ||
if (req.userId > 0) | ||
return res.redirect("/"); | ||
next(); | ||
}; | ||
// Prevent access to "anonymous pages" | ||
unlogged: function(req, res, next) { | ||
if (req.userId > 0) | ||
return res.redirect("/"); | ||
next(); | ||
}, | ||
|
||
// Prevent direct access to AJAX results | ||
Access.ajax = function(req, res, next) | ||
{ | ||
if (!req.xhr) | ||
return res.json({errmsg: "Unauthorized access"}); | ||
next(); | ||
} | ||
// Prevent direct access to AJAX results | ||
ajax: function(req, res, next) { | ||
if (!req.xhr) | ||
return res.json({errmsg: "Unauthorized access"}); | ||
next(); | ||
}, | ||
|
||
// Check for errors before callback (continue page loading). TODO: better name. | ||
Access.checkRequest = function(res, err, out, msg, cb) | ||
{ | ||
if (!!err) | ||
return res.json({errmsg: err.errmsg || err.toString()}); | ||
if (!out | ||
|| (Array.isArray(out) && out.length == 0) | ||
|| (typeof out === "object" && Object.keys(out).length == 0)) | ||
{ | ||
return res.json({errmsg: msg}); | ||
} | ||
cb(); | ||
// Check for errors before callback (continue page loading). TODO: better name. | ||
checkRequest: function(res, err, out, msg, cb) { | ||
if (!!err) | ||
return res.json({errmsg: err.errmsg || err.toString()}); | ||
if (!out | ||
|| (Array.isArray(out) && out.length == 0) | ||
|| (typeof out === "object" && Object.keys(out).length == 0)) | ||
{ | ||
return res.json({errmsg: msg}); | ||
} | ||
cb(); | ||
}, | ||
} | ||
|
||
module.exports = Access; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
var TokenGen = {}; | ||
|
||
TokenGen.rand = function() | ||
module.exports = | ||
{ | ||
return Math.random().toString(36).substr(2); // remove `0.` | ||
}; | ||
rand: function() { | ||
return Math.random().toString(36).substr(2); // remove `0.` | ||
}, | ||
|
||
TokenGen.generate = function(tlen) | ||
{ | ||
var res = ""; | ||
var nbRands = Math.ceil(tlen/10); //10 = min length of a rand() string | ||
for (var i = 0; i < nbRands; i++) | ||
res += TokenGen.rand(); | ||
return res.substr(0, tlen); | ||
generate: function(tlen) { | ||
var res = ""; | ||
var nbRands = Math.ceil(tlen/10); //10 = min length of a rand() string | ||
for (var i = 0; i < nbRands; i++) | ||
res += TokenGen.rand(); | ||
return res.substr(0, tlen); | ||
}, | ||
} | ||
|
||
module.exports = TokenGen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters