This file contains hidden or 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
| var UserSchema = new Schema({ | |
| // existing properties | |
| username: { type: String, required: true, index: { unique: true } }, | |
| password: { type: String, required: true }, | |
| // new properties | |
| loginAttempts: { type: Number, required: true, default: 0 }, | |
| lockUntil: { type: Number } | |
| }); |
This file contains hidden or 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
| // expose enum on the model | |
| UserSchema.statics.failedLogin = { | |
| NOT_FOUND: 0, | |
| PASSWORD_INCORRECT: 1, | |
| MAX_ATTEMPTS: 2 | |
| }; |
This file contains hidden or 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
| var mongoose = require('mongoose'), | |
| Schema = mongoose.Schema, | |
| bcrypt = require('bcrypt'), | |
| SALT_WORK_FACTOR = 10, | |
| // these values can be whatever you want - we're defaulting to a | |
| // max of 5 attempts, resulting in a 2 hour lock | |
| MAX_LOGIN_ATTEMPTS = 5, | |
| LOCK_TIME = 2 * 60 * 60 * 1000; | |
| var UserSchema = new Schema({ |
This file contains hidden or 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
| var mongoose = require('mongoose'), | |
| User = require('./user-model'); | |
| var connStr = 'mongodb://localhost:27017/mongoose-bcrypt-test'; | |
| mongoose.connect(connStr, function(err) { | |
| if (err) throw err; | |
| console.log('Successfully connected to MongoDB'); | |
| }); | |
| // create a user a new user |
This file contains hidden or 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
| config.cfg | |
| precog.sh | |
| precog.bat |
This file contains hidden or 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
| queryExecutor { | |
| mongo { | |
| server = "mongodb://localhost:27017" | |
| } | |
| } |
This file contains hidden or 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
| security { | |
| masterAccount { | |
| apiKey = "12345678-1234-1234-1234-123456789abc" | |
| } | |
| } |
This file contains hidden or 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
| server { | |
| port = 8888 | |
| } | |
| ... | |
| labcoat { | |
| port = 8000 | |
| } |
This file contains hidden or 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
| server { | |
| port = 8888 | |
| } | |
| ... | |
| labcoat { | |
| port = 8000 | |
| } |
This file contains hidden or 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
| #inserting documents | |
| t.save( { _id: 1, title: "Physics World", text: "Physics World is the | |
| membership magazine of the Institute of Physics."} ); | |
| t.save( { _id: 2, title: "A break away!", text: "'A break away!' is an | |
| 1891 painting by Australian artist Tom Roberts."} ); | |
| t.save( { _id: 3, title: "Mahim Bora", text: "Mahim Bora (b.1926) is an | |
| Indian writer and educationist from Assam state."}); |