-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MacBook Pro
committed
Jun 24, 2017
0 parents
commit bad27c9
Showing
4,638 changed files
with
505,715 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,37 @@ | ||
/** | ||
* Created by macbookpro on 18/06/2017. | ||
*/ | ||
function User () { | ||
this.username = ""; | ||
this.password = ""; | ||
this.email = ""; | ||
} | ||
|
||
User.prototype = { | ||
setUserName : function (username) { | ||
this.username = username; | ||
}, | ||
|
||
getUserName: function () { | ||
return this.username; | ||
}, | ||
|
||
setPassword : function (password) { | ||
this.password = password; | ||
}, | ||
|
||
getPassword: function () { | ||
return this.password; | ||
}, | ||
|
||
setEmail : function (email) { | ||
this.email = email; | ||
}, | ||
|
||
getEmail: function () { | ||
return this.email; | ||
} | ||
}; | ||
|
||
|
||
module.exports = User; |
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,58 @@ | ||
var sleep = require('system-sleep'); | ||
|
||
function Count () { | ||
|
||
} | ||
|
||
Count.prototype = { | ||
countUser: function (user) { | ||
var test = true; | ||
|
||
|
||
var MongoClient = require('mongodb').MongoClient; | ||
|
||
MongoClient.connect("mongodb://localhost:27017/Battleship", function(err, db) { | ||
if (!err) { | ||
db.collection('user').find({"email":user.getEmail()}).count() | ||
.then(function(numItems) { | ||
|
||
|
||
if(numItems > 0){ | ||
test = false; | ||
} | ||
}) | ||
} | ||
}); | ||
|
||
var sleep = require('system-sleep'); | ||
sleep(200); | ||
return test; | ||
}, | ||
|
||
countUserForLogin: function(user) { | ||
var test = false; | ||
var MongoClient = require('mongodb').MongoClient; | ||
|
||
MongoClient.connect("mongodb://localhost:27017/Battleship", function(err, db) { | ||
if (!err) { | ||
db.collection('user').find( { $and : [ {"email":user.getEmail()}, {"password": user.getPassword() } ] }).count() | ||
.then(function(numItems) { | ||
|
||
if(numItems > 0){ | ||
test = true; | ||
|
||
} | ||
}) | ||
} | ||
}); | ||
|
||
var sleep = require('system-sleep'); | ||
sleep(200); | ||
|
||
return test; | ||
} | ||
}; | ||
|
||
|
||
|
||
module.exports = Count; |
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,30 @@ | ||
/** | ||
* Created by macbookpro on 18/06/2017. | ||
*/ | ||
|
||
function Insert () { | ||
|
||
} | ||
|
||
Insert.prototype = { | ||
insertUser : function (user) { | ||
const User = require('../Beans/User'); | ||
|
||
var MongoClient = require('mongodb').MongoClient; | ||
|
||
MongoClient.connect("mongodb://localhost:27017/Battleship", function(err, db) { | ||
if (!err) { | ||
var collection = db.collection('user'); | ||
|
||
var doc1 = {username: user.getUserName(), password: user.getPassword(), email: user.getEmail()}; | ||
collection.insert(doc1); | ||
|
||
} | ||
}); | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
module.exports = Insert; |
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,44 @@ | ||
/** | ||
* Created by macbookpro on 19/06/2017. | ||
*/ | ||
|
||
var sleep = require('system-sleep'); | ||
|
||
function SelectUser () { | ||
|
||
} | ||
|
||
SelectUser.prototype = { | ||
selectUser : function (user) { | ||
var retur; | ||
const User = require('../Beans/User'); | ||
var user2 = new User(); | ||
|
||
var MongoClient = require('mongodb').MongoClient; | ||
|
||
MongoClient.connect("mongodb://localhost:27017/Battleship", function(err, db) { | ||
if (!err) { | ||
|
||
|
||
|
||
db.collection('user').findOne({ $and : [ {"email":user.getEmail()}, {"password": user.getPassword() } ] }, function(err, document) { | ||
user2.setPassword(document.password); | ||
user2.setEmail(document.email); | ||
user2.setUserName(document.username); | ||
|
||
|
||
}); | ||
|
||
} | ||
}); | ||
|
||
var sleep = require('system-sleep'); | ||
sleep(200); | ||
|
||
return user2; | ||
} | ||
} | ||
|
||
|
||
|
||
module.exports = SelectUser; |
Oops, something went wrong.