Added adminpanel to this repo

This commit is contained in:
Kasper Rynning-Tønnesen
2018-02-05 19:46:03 +01:00
parent 38bceb1a53
commit 01a42c7d68
40 changed files with 1561 additions and 35 deletions

24
server/models/user.js Normal file
View File

@@ -0,0 +1,24 @@
// app/models/user.js
// load the things we need
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
// define the schema for our user model
var userSchema = mongoose.Schema({
username : String,
password : String,
});
// methods ======================
// generating a hash
userSchema.methods.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};
// checking if password is valid
userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
// create the model for users and expose it to our app
module.exports = mongoose.model('User', userSchema);