Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
tameeshB committed Dec 25, 2017
1 parent a38f0ef commit 4878a65
Show file tree
Hide file tree
Showing 13 changed files with 3,989 additions and 325 deletions.
51 changes: 27 additions & 24 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,48 @@ var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');

var userSchema = mongoose.Schema({
username: String,
name : String,
username: String,
name: String,
hash: String,
rooms: [{id : Number,roomname: String}],
local : {
email : String,
password : String,
rooms: [{
id: Number,
roomname: String
}],
local: {
email: String,
password: String,
},
facebook : {
id : String,
token : String,
name : String,
email : String
facebook: {
id: String,
token: String,
name: String,
email: String
},
twitter : {
id : String,
token : String,
displayName : String,
username : String
twitter: {
id: String,
token: String,
displayName: String,
username: String
},
google : {
id : String,
token : String,
email : String,
name : String
google: {
id: String,
token: String,
email: String,
name: String
}

});

userSchema.methods.generateHash = function(password) {
userSchema.methods.generateHash = function (password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};

userSchema.methods.generateAccessHash = function (username, password) {
return bcrypt.hashSync(username + password, bcrypt.genSaltSync(8), null);
};

userSchema.methods.validPassword = function(password) {
userSchema.methods.validPassword = function (password) {
return bcrypt.compareSync(password, this.local.password);
};

module.exports = mongoose.model('User', userSchema);
module.exports = mongoose.model('User', userSchema);
Loading

0 comments on commit 4878a65

Please sign in to comment.