overleaf/services/web/app/coffee/models/User.coffee

85 lines
3.5 KiB
CoffeeScript
Raw Normal View History

2014-02-12 10:23:40 +00:00
Project = require('./Project').Project
Settings = require 'settings-sharelatex'
_ = require('underscore')
mongoose = require('mongoose')
uuid = require('uuid')
2014-02-12 10:23:40 +00:00
Schema = mongoose.Schema
ObjectId = Schema.ObjectId
UserSchema = new Schema
email : {type : String, default : ''}
2018-05-28 14:08:37 +00:00
emails: [{
email: { type : String, default : '' },
createdAt: { type : Date, default: () -> new Date() }
}],
2014-02-12 10:23:40 +00:00
first_name : {type : String, default : ''}
last_name : {type : String, default : ''}
2014-06-11 11:46:28 +00:00
role : {type : String, default : ''}
institution : {type : String, default : ''}
2014-02-12 10:23:40 +00:00
hashedPassword : String
isAdmin : {type : Boolean, default : false}
confirmed : {type : Boolean, default : false}
signUpDate : {type : Date, default: () -> new Date() }
lastLoggedIn : {type : Date}
loginCount : {type : Number, default: 0}
holdingAccount : {type : Boolean, default: false}
ace : {
mode : {type : String, default: 'none'}
theme : {type : String, default: 'textmate'}
fontSize : {type : Number, default:'12'}
autoComplete : {type : Boolean, default: true}
autoPairDelimiters : {type : Boolean, default: true}
spellCheckLanguage : {type : String, default: "en"}
pdfViewer : {type : String, default: "pdfjs"}
syntaxValidation : {type : Boolean}
fontFamily : {type : String}
lineHeight : {type : String}
}
2014-02-12 10:23:40 +00:00
features : {
collaborators: { type:Number, default: Settings.defaultFeatures.collaborators }
versioning: { type:Boolean, default: Settings.defaultFeatures.versioning }
dropbox: { type:Boolean, default: Settings.defaultFeatures.dropbox }
github: { type:Boolean, default: Settings.defaultFeatures.github }
compileTimeout: { type:Number, default: Settings.defaultFeatures.compileTimeout }
compileGroup: { type:String, default: Settings.defaultFeatures.compileGroup }
templates: { type:Boolean, default: Settings.defaultFeatures.templates }
references: { type:Boolean, default: Settings.defaultFeatures.references }
trackChanges: { type:Boolean, default: Settings.defaultFeatures.trackChanges }
mendeley: { type:Boolean, default: Settings.defaultFeatures.mendeley }
referencesSearch: { type:Boolean, default: Settings.defaultFeatures.referencesSearch }
}
2014-02-12 10:23:40 +00:00
referal_id : {type:String, default:() -> uuid.v4().split("-")[0]}
refered_users: [ type:ObjectId, ref:'User' ]
refered_user_count: { type:Number, default: 0 }
subscription:
recurlyToken : String
freeTrialExpiresAt: Date
freeTrialDowngraded: Boolean
freeTrialPlanCode: String
# This is poorly named. It does not directly correspond
# to whether the user has has a free trial, but rather
# whether they should be allowed one in the future.
# For example, a user signing up directly for a paid plan
# has this set to true, despite never having had a free trial
hadFreeTrial: {type: Boolean, default: false}
2016-04-01 10:36:19 +00:00
refProviders: {
mendeley: Boolean # coerce the refProviders values to Booleans
zotero: Boolean
}
betaProgram: { type:Boolean, default: false}
2017-08-07 10:24:04 +00:00
overleaf:
id: { type: Number }
accessToken: { type: String }
2017-08-09 09:50:05 +00:00
refreshToken: { type: String }
2018-01-26 16:44:14 +00:00
awareOfV2: { type:Boolean, default: false }
2014-02-12 10:23:40 +00:00
conn = mongoose.createConnection(Settings.mongo.url, {
server: {poolSize: Settings.mongo.poolSize || 10},
config: {autoIndex: false}
})
2014-02-12 10:23:40 +00:00
User = conn.model('User', UserSchema)
model = mongoose.model 'User', UserSchema
exports.User = User