User.coffee 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Project = require('./Project').Project
  2. Settings = require 'settings-sharelatex'
  3. _ = require('underscore')
  4. mongoose = require('mongoose')
  5. uuid = require('uuid')
  6. Schema = mongoose.Schema
  7. ObjectId = Schema.ObjectId
  8. UserSchema = new Schema
  9. email : {type : String, default : ''}
  10. first_name : {type : String, default : ''}
  11. last_name : {type : String, default : ''}
  12. role : {type : String, default : ''}
  13. institution : {type : String, default : ''}
  14. hashedPassword : String
  15. isAdmin : {type : Boolean, default : false}
  16. confirmed : {type : Boolean, default : false}
  17. signUpDate : {type : Date, default: () -> new Date() }
  18. lastLoggedIn : {type : Date}
  19. loginCount : {type : Number, default: 0}
  20. holdingAccount : {type : Boolean, default: false}
  21. ace : {
  22. mode : {type : String, default: 'none'}
  23. theme : {type : String, default: 'textmate'}
  24. fontSize : {type : Number, default:'12'}
  25. autoComplete: {type : Boolean, default: true}
  26. spellCheckLanguage : {type : String, default: "en"}
  27. pdfViewer : {type : String, default: "pdfjs"}
  28. syntaxValidation : {type : Boolean}
  29. }
  30. features : {
  31. collaborators: { type:Number, default: Settings.defaultFeatures.collaborators }
  32. versioning: { type:Boolean, default: Settings.defaultFeatures.versioning }
  33. dropbox: { type:Boolean, default: Settings.defaultFeatures.dropbox }
  34. github: { type:Boolean, default: Settings.defaultFeatures.github }
  35. compileTimeout: { type:Number, default: Settings.defaultFeatures.compileTimeout }
  36. compileGroup: { type:String, default: Settings.defaultFeatures.compileGroup }
  37. templates: { type:Boolean, default: Settings.defaultFeatures.templates }
  38. references: { type:Boolean, default: Settings.defaultFeatures.references }
  39. trackChanges: { type:Boolean, default: Settings.defaultFeatures.trackChanges }
  40. }
  41. referal_id : {type:String, default:() -> uuid.v4().split("-")[0]}
  42. refered_users: [ type:ObjectId, ref:'User' ]
  43. refered_user_count: { type:Number, default: 0 }
  44. subscription:
  45. recurlyToken : String
  46. freeTrialExpiresAt: Date
  47. freeTrialDowngraded: Boolean
  48. freeTrialPlanCode: String
  49. # This is poorly named. It does not directly correspond
  50. # to whether the user has has a free trial, but rather
  51. # whether they should be allowed one in the future.
  52. # For example, a user signing up directly for a paid plan
  53. # has this set to true, despite never having had a free trial
  54. hadFreeTrial: {type: Boolean, default: false}
  55. refProviders: {
  56. mendeley: Boolean # coerce the refProviders values to Booleans
  57. zotero: Boolean
  58. }
  59. betaProgram: { type:Boolean, default: false}
  60. conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: 10)
  61. User = conn.model('User', UserSchema)
  62. model = mongoose.model 'User', UserSchema
  63. exports.User = User