Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General updates, some modules added.
- Loading branch information
Showing
10 changed files
with
117 additions
and
11 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 |
---|---|---|
|
@@ -14,4 +14,5 @@ attic | |
.Trashes | ||
|
||
# Own generated | ||
config/runtime.json | ||
public/stylesheets/bp.css |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
port: 3000 | ||
|
||
verbose: true |
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,2 @@ | ||
|
||
verbose: false |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
{ | ||
"app": { | ||
"message": "Hello sfrom nbp!" | ||
} | ||
} |
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,6 @@ | ||
|
||
{ | ||
"app": { | ||
"message": "Hola desde nbp!" | ||
} | ||
} |
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,67 @@ | ||
|
||
/** | ||
* User Schema. | ||
*/ | ||
|
||
var | ||
mongoose = require('mongoose'), | ||
Schema = mongoose.Schema, | ||
bcrypt = require('bcrypt'), | ||
SALT_WORK_FACTOR = 10; | ||
|
||
var UserSchema = new Schema({ | ||
username: { | ||
type: String, | ||
required: true, | ||
index: { | ||
unique: true | ||
} | ||
}, | ||
password: { | ||
type: String, | ||
required: true | ||
}, | ||
role: { | ||
type: String, | ||
'default': 'user', | ||
enum: [ | ||
'user', | ||
'admin' | ||
] | ||
} | ||
}); | ||
|
||
UserSchema.pre('save', function (next) { | ||
var user = this; | ||
// only hash the password if it has been modified (or is new) | ||
if (!user.isModified('password')) { | ||
return next(); | ||
} | ||
|
||
// generate a salt | ||
bcrypt.genSalt(SALT_WORK_FACTOR, function (err, salt) { | ||
if (err) { | ||
return next(err); | ||
} | ||
// hash the password using our new salt | ||
bcrypt.hash(user.password, salt, function (err, hash) { | ||
if (err) { | ||
return next(err); | ||
} | ||
// override the cleartext password with the hashed one | ||
user.password = hash; | ||
next(); | ||
}); | ||
}); | ||
}); | ||
|
||
UserSchema.methods.comparePassword = function (candidatePassword, cb) { | ||
bcrypt.compare(candidatePassword, this.password, function (err, isMatch) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
cb(null, isMatch); | ||
}); | ||
}; | ||
|
||
module.exports = mongoose.model('User', UserSchema); |
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,4 +1,4 @@ | ||
extends box | ||
|
||
append box | ||
h2 Hello, from nbp! | ||
h2= t('app.message') |