All files / src/model users.coffee

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x 1x 1x   1x                                       1x  
mongoose = require "mongoose"
server = require "../server"
connectionDefault = server.connectionDefault
Schema = mongoose.Schema
 
UserSchema = new Schema
  "firstname":          type: String, required: true
  "surname":            type: String, required: true
  "email":              type: String, required: true, unique: true
  "passwordAlgorithm":  String
  "passwordHash":       String
  "passwordSalt":       String
  "groups":             [String]
  "msisdn":             String
  "dailyReport":        Boolean
  "weeklyReport":       Boolean
  "settings":           Object
  "token":              String
  "tokenType":
    type:     String
    enum:     ['newUser', 'existingUser', null] # null is needed as we used nulls to clear to token and tokenType
  "expiry":             Date
  "locked":             Boolean
 
#compile the User Schema into a Model
exports.User = connectionDefault.model 'User', UserSchema