-
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.
Ravens desire to inflict pensive depression.
- Loading branch information
1 parent
fefdc7c
commit 451c1e3
Showing
44 changed files
with
1,091 additions
and
2,376 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
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,4 +1,5 @@ | ||
node_modules/ | ||
.idea/ | ||
*.log.* | ||
uploads/ | ||
uploads/ | ||
package-lock.json |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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,22 +1,43 @@ | ||
let mongoose = require("mongoose"), | ||
// bcrypt = require("bcrypt"), | ||
bcrypt = require("bcrypt-nodejs"), | ||
shortid = require("shortid"); | ||
|
||
const SALT_FACTOR = 4; | ||
|
||
let modSchema = new mongoose.Schema({ | ||
_id: { type: String, required: true, default: shortid.generate }, | ||
email: { type: String, required: true }, | ||
username: { type: String, required: true }, | ||
password: { type: String, required: true } | ||
}, { collection: _db.get("db.collection.mods") }); | ||
|
||
// TODO: implement check password method | ||
// modSchema.methods.checkPassword = function(guess, done) { | ||
// bcrypt.compare(guess, this.password, function(err, match) { | ||
// done(err, match); | ||
// }); | ||
// }; | ||
// TODO: remove this test implementation of the checkPassword method | ||
function noop() {}; | ||
|
||
modSchema.pre('save', function (done) { | ||
let user = this; //Reference to user model | ||
|
||
if (!user.isModified("password")) { | ||
return done(); | ||
} | ||
|
||
bcrypt.genSalt(SALT_FACTOR, function (err, salt) { | ||
if (err) { | ||
return done(err); | ||
} | ||
bcrypt.hash(user.password, salt, noop, function (err, hashedPassword) { | ||
if (err) { | ||
return done(err); | ||
} | ||
user.password = hashedPassword; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
modSchema.methods.checkPassword = function(guess, done) { | ||
done(null, true); | ||
} | ||
bcrypt.compare(guess, this.password, function(err, isMatch) { | ||
done(err, isMatch); | ||
}); | ||
}; | ||
|
||
let Mod = mongoose.model('Mod', modSchema); | ||
module.exports = Mod; |
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 |
---|---|---|
|
@@ -30,4 +30,4 @@ module.exports = { | |
} | ||
} | ||
|
||
} | ||
}; |
Oops, something went wrong.