From c7bc708db06657ab19100dfbce1b5673905ab225 Mon Sep 17 00:00:00 2001 From: btouellette Date: Tue, 12 May 2020 00:07:00 +0000 Subject: [PATCH 1/7] adding debug code to username route --- app/routes.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/routes.js b/app/routes.js index 50bb9a3..31b3deb 100644 --- a/app/routes.js +++ b/app/routes.js @@ -42,25 +42,37 @@ module.exports = function(app, passport, client) { // process the username form app.post('/username', isLoggedIn, function(req, res) { + console.log(req.headers['x-request-id'] + ' - selecting new username - ' + JSON.stringify(req)); if(!req.user.username) { var username = req.body.username.toLowerCase(); + console.log(req.headers['x-request-id'] + ' - testing valid'); if(/^[a-z0-9_]{1,12}$/.test(username)) { + console.log(req.headers['x-request-id'] + ' - setting username'); User.findByIdAndUpdate(req.user._id, { $set: { username: username }}, function(err) { + console.log(req.headers['x-request-id'] + ' - setting username callback'); if(err) { + console.log(req.headers['x-request-id'] + ' - username callback error - ' + JSON.stringify(err)); if(err.lastErrorObject && err.lastErrorObject.code === 11001) { + console.log(req.headers['x-request-id'] + ' - setting username callback error taken'); req.flash('usernameMessage', 'Username already taken'); } else { + console.log(req.headers['x-request-id'] + ' - setting username callback error unknown'); req.flash('usernameMessage', err.errmsg); } + console.log(req.headers['x-request-id'] + ' - reloading username'); res.redirect('/username'); } else { + console.log(req.headers['x-request-id'] + ' - set user name sending to game'); res.redirect('/game'); } }); } else { + console.log(req.headers['x-request-id'] + ' - not valid'); req.flash('usernameMessage', username.length > 12 ? 'Username too long' : username.length === 0 ? 'Username too short' : 'Username using invalid characters'); res.redirect('/username'); } + } else { + console.log(req.headers['x-request-id'] + ' - already has username'); } }); From 4499931e80970f0d4ec9f1f9fd49152292ed888a Mon Sep 17 00:00:00 2001 From: btouellette Date: Tue, 12 May 2020 18:03:05 +0000 Subject: [PATCH 2/7] adding username display to friends list --- content/css/game.css | 8 ++++++++ views/game.ejs | 1 + 2 files changed, 9 insertions(+) diff --git a/content/css/game.css b/content/css/game.css index c1642e5..6a93e39 100644 --- a/content/css/game.css +++ b/content/css/game.css @@ -392,6 +392,14 @@ html, body margin-right: 10px; } +#username-info +{ + margin-left: 10px; + margin-right: 10px; + padding-top: 3px; + margin-bottom: 5px; +} + #username-alert { margin-left: 10px; diff --git a/views/game.ejs b/views/game.ejs index 2c7f944..2375c4e 100644 --- a/views/game.ejs +++ b/views/game.ejs @@ -56,6 +56,7 @@
FRIENDS +
You: <%- user.username %>
From 368eb6f1501196203a2d53b77479d4512bd5a89c Mon Sep 17 00:00:00 2001 From: Brian Ouellette Date: Tue, 12 May 2020 19:16:32 -0700 Subject: [PATCH 3/7] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..12bdddf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Brian Ouellette + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From afeb65f59c2ecc49dcd70b10f3d105a25d32633e Mon Sep 17 00:00:00 2001 From: btouellette Date: Thu, 14 May 2020 00:12:29 +0000 Subject: [PATCH 4/7] using circular json parser --- app/routes.js | 5 +++-- package.json | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/routes.js b/app/routes.js index 31b3deb..42af444 100644 --- a/app/routes.js +++ b/app/routes.js @@ -1,4 +1,5 @@ var User = require('./models/user'); +const {parse, stringify} = require('flatted/cjs'); //TODO: confirm e-mail before allowing into game @@ -42,7 +43,7 @@ module.exports = function(app, passport, client) { // process the username form app.post('/username', isLoggedIn, function(req, res) { - console.log(req.headers['x-request-id'] + ' - selecting new username - ' + JSON.stringify(req)); + console.log(req.headers['x-request-id'] + ' - selecting new username - ' + stringify(req)); if(!req.user.username) { var username = req.body.username.toLowerCase(); console.log(req.headers['x-request-id'] + ' - testing valid'); @@ -51,7 +52,7 @@ module.exports = function(app, passport, client) { User.findByIdAndUpdate(req.user._id, { $set: { username: username }}, function(err) { console.log(req.headers['x-request-id'] + ' - setting username callback'); if(err) { - console.log(req.headers['x-request-id'] + ' - username callback error - ' + JSON.stringify(err)); + console.log(req.headers['x-request-id'] + ' - username callback error - ' + stringify(err)); if(err.lastErrorObject && err.lastErrorObject.code === 11001) { console.log(req.headers['x-request-id'] + ' - setting username callback error taken'); req.flash('usernameMessage', 'Username already taken'); diff --git a/package.json b/package.json index 02bcb4f..878799e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "ejs": "^2.5.7", "express": "^4.15.4", "express-session": "^1.15.5", + "flatted": "^2.0.2", "helmet": "^3.8.1", "mongoose": "^4.11.6", "moniker": "^0.1.2", @@ -38,6 +39,19 @@ "eslint": "^3.19.0" }, "scripts": { - "lint": "eslint app" - } + "lint": "eslint app", + "start": "node server.js" + }, + "description": "Multiplayer web game using the same rules as Carcassone. Currently supports the base game and the Inns and Cathedrals expansion.", + "version": "1.0.0", + "repository": { + "type": "git", + "url": "git+https://github.com/btouellette/concarneau.git" + }, + "author": "Brian Ouellette", + "license": "MIT", + "bugs": { + "url": "https://github.com/btouellette/concarneau/issues" + }, + "homepage": "https://github.com/btouellette/concarneau#readme" } From 5f590548827ac6e2ef2421611a22f923108ad690 Mon Sep 17 00:00:00 2001 From: btouellette Date: Fri, 15 May 2020 16:51:56 +0000 Subject: [PATCH 5/7] adding redirect for double set usernames --- app/routes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/routes.js b/app/routes.js index 42af444..756d76b 100644 --- a/app/routes.js +++ b/app/routes.js @@ -74,6 +74,7 @@ module.exports = function(app, passport, client) { } } else { console.log(req.headers['x-request-id'] + ' - already has username'); + res.redirect('/game'); } }); From 6fa856633519ed3639e4a3fd137035d50b6831f4 Mon Sep 17 00:00:00 2001 From: Brian Ouellette Date: Mon, 18 May 2020 09:50:56 -0700 Subject: [PATCH 6/7] updating socket.io version --- views/game.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/game.ejs b/views/game.ejs index 2375c4e..00664c3 100644 --- a/views/game.ejs +++ b/views/game.ejs @@ -200,7 +200,7 @@
- + From 92b5e42370778f4c4c7ccc29558162075fbb430a Mon Sep 17 00:00:00 2001 From: Brian Ouellette Date: Fri, 26 Jun 2020 15:10:49 -0700 Subject: [PATCH 7/7] Update rules link --- views/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/index.ejs b/views/index.ejs index 9da94aa..545d317 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -29,7 +29,7 @@

Concarneau

An implementation of Carcassonne using D3.js and Node.js created by Brian Ouellette

-

Unfamiliar with Carcassonne? You can read the rules here

+

Unfamiliar with Carcassonne? You can read the rules here

Local Login Local Signup Facebook