Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
20b6591
milestone 1 with bad css
IronBiscuit May 21, 2020
1df2ccb
trigger
IronBiscuit May 21, 2020
83eb7fa
improved milestone 1
IronBiscuit May 25, 2020
c6b7269
again
IronBiscuit May 25, 2020
447f43e
hello
IronBiscuit May 25, 2020
de8d5eb
helloo
IronBiscuit May 25, 2020
a3ff269
hellooo
IronBiscuit May 25, 2020
699ba8f
helloooo
IronBiscuit May 25, 2020
20311e9
hellooooo
IronBiscuit May 25, 2020
6d8467b
hello darkness
IronBiscuit May 25, 2020
1b56398
hello darknesss
IronBiscuit May 25, 2020
9598ae4
fake milestone 1
IronBiscuit May 25, 2020
df7740d
please work
IronBiscuit May 25, 2020
8eed924
final milestone1
IronBiscuit May 25, 2020
4da8dac
reduce lag
IronBiscuit May 25, 2020
4cca27a
reduce lag
IronBiscuit May 25, 2020
1a61050
reduce lag
IronBiscuit May 25, 2020
8d47edd
reduce lag
IronBiscuit May 25, 2020
827b3f4
added chat
IronBiscuit May 31, 2020
5590327
reformed code
IronBiscuit Jun 10, 2020
3d1846d
reformed code
IronBiscuit Jun 10, 2020
1ce32c8
reformed code
IronBiscuit Jun 10, 2020
f91adf9
reformed code
IronBiscuit Jun 10, 2020
bf95500
reformed code
IronBiscuit Jun 10, 2020
1fc506b
reformed code
IronBiscuit Jun 10, 2020
a271474
wall collision
IronBiscuit Jun 12, 2020
afe527d
improved camera
IronBiscuit Jun 13, 2020
5e944db
improved camera
IronBiscuit Jun 13, 2020
3af5a68
hallelujah
IronBiscuit Jun 13, 2020
59c7901
hallelujah
IronBiscuit Jun 13, 2020
6fd1d2f
hallelujah
IronBiscuit Jun 13, 2020
8a62eb8
hallelujah
IronBiscuit Jun 13, 2020
2051d2f
hallelujah
IronBiscuit Jun 13, 2020
3e1c886
hallelujah
IronBiscuit Jun 25, 2020
cc184ca
queue system
IronBiscuit Jun 29, 2020
bc8fe9b
improved queue
IronBiscuit Jun 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions client/test.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<canvas id="ctx" width="500" height="500" style="border:1px solid #000000;"></canvas>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();

var random = Math.random();

var happy = function(){
socket.emit('happy',{
reason:'its my birthday' + random
});
}

socket.on('serverMsg',function(data){
console.log(data.msg);
});


</script>

<button onclick="happy()">Happy</button>
16 changes: 16 additions & 0 deletions config/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
ensureAuthenticated: function(req, res, next) {
if (req.isAuthenticated()) {
return next();
}
req.flash('error_msg', 'Please log in first');
res.redirect('/login');
},
forwardAuthenticated: function(req, res, next) {
if (!req.isAuthenticated()) {
return next();
}
//req.logout();
res.redirect('/dashboard');
}
};
3 changes: 3 additions & 0 deletions config/keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
MongoURI: 'mongodb+srv://WebGame:webgamepassword@webgame-bedjh.mongodb.net/test?retryWrites=true&w=majority'
}
40 changes: 40 additions & 0 deletions config/passport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const LocalStrategy = require('passport-local').Strategy;
const bcrypt = require('bcryptjs');

// Load User model
const User = require('../models/User');

module.exports = function(passport) {
passport.use(
new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
// Match user
User.findOne({
email: email
}).then(user => {
if (!user) {
return done(null, false, { message: 'That email is not registered' });
}

// Match password
bcrypt.compare(password, user.password, (err, isMatch) => {
if (err) throw err;
if (isMatch) {
return done(null, user);
} else {
return done(null, false, { message: 'Password incorrect' });
}
});
});
})
);

passport.serializeUser(function(user, done) {
done(null, user.id);
});

passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
});
};
24 changes: 24 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const mongoose = require('mongoose');

const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
},
date: {
type: Date,
default: Date.now
}
});

const User = mongoose.model('User', UserSchema);

module.exports = User;
19 changes: 19 additions & 0 deletions models/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class ErrorHandler extends Error {
constructor(statusCode, message) {
super();
this.statusCode = statusCode;
this.message = message;
}
}
const handleError = (err, res) => {
const { statusCode, message } = err;
res.status(statusCode).json({
status: "error",
statusCode,
message
});
};

module.exports = {
ErrorHandler, handleError
}
Loading