mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-10 07:47:29 -05:00
34 lines
891 B
JavaScript
34 lines
891 B
JavaScript
var mongoose = require('mongoose');
|
|
var bcrypt = require('bcrypt-nodejs');
|
|
var User = require('./user');
|
|
|
|
var systemSchema = mongoose.Schema({
|
|
name: String,
|
|
shortName: String,
|
|
systemType: String,
|
|
county: String,
|
|
country: String,
|
|
city: String,
|
|
state: String,
|
|
description: String,
|
|
showScreenName: Boolean,
|
|
callAvg: Number,
|
|
callCount: Number,
|
|
ignoreUnknownTalkgroup : Boolean,
|
|
active: {type: Boolean, default: false},
|
|
lastActive: Date,
|
|
planType: {type: Number, default: 0},
|
|
userId: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
key: String
|
|
});
|
|
|
|
systemSchema.methods.generateHash = function(password) {
|
|
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
|
|
};
|
|
|
|
systemSchema.methods.validPassword = function(password) {
|
|
return bcrypt.compareSync(password, this.local.password);
|
|
};
|
|
|
|
module.exports = mongoose.model('System', systemSchema);
|