2014-02-12 05:23:40 -05:00
|
|
|
Project = require('./Project').Project
|
|
|
|
Settings = require 'settings-sharelatex'
|
|
|
|
_ = require('underscore')
|
2017-05-10 10:31:17 -04:00
|
|
|
mongoose = require('mongoose')
|
2017-01-23 05:03:16 -05:00
|
|
|
uuid = require('uuid')
|
2014-02-12 05:23:40 -05:00
|
|
|
Schema = mongoose.Schema
|
|
|
|
ObjectId = Schema.ObjectId
|
|
|
|
|
2019-01-29 15:14:59 -05:00
|
|
|
# See https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/574698#574698
|
|
|
|
MAX_EMAIL_LENGTH = 254
|
|
|
|
|
2014-02-12 05:23:40 -05:00
|
|
|
UserSchema = new Schema
|
2019-01-29 15:14:59 -05:00
|
|
|
email : {type : String, default : '', maxlength: MAX_EMAIL_LENGTH }
|
2018-05-28 10:08:37 -04:00
|
|
|
emails: [{
|
2019-01-29 15:14:59 -05:00
|
|
|
email: { type : String, default : '', maxlength: MAX_EMAIL_LENGTH },
|
2018-10-08 08:37:12 -04:00
|
|
|
reversedHostname: { type : String, default : '' },
|
2018-06-19 08:55:34 -04:00
|
|
|
createdAt: { type : Date, default: () -> new Date() },
|
|
|
|
confirmedAt: { type: Date }
|
2018-05-28 10:08:37 -04:00
|
|
|
}],
|
2014-02-12 05:23:40 -05:00
|
|
|
first_name : {type : String, default : ''}
|
|
|
|
last_name : {type : String, default : ''}
|
2014-06-11 07:46:28 -04:00
|
|
|
role : {type : String, default : ''}
|
|
|
|
institution : {type : String, default : ''}
|
2014-02-12 05:23:40 -05:00
|
|
|
hashedPassword : String
|
|
|
|
isAdmin : {type : Boolean, default : false}
|
2019-01-11 09:17:27 -05:00
|
|
|
staffAccess: {
|
|
|
|
publisherMetrics: {type : Boolean, default: false}
|
|
|
|
publisherManagement: {type : Boolean, default: false}
|
|
|
|
institutionMetrics: {type : Boolean, default: false}
|
|
|
|
institutionManagement: {type : Boolean, default: false}
|
|
|
|
groupMetrics: {type : Boolean, default: false}
|
|
|
|
groupManagement: {type : Boolean, default: false}
|
|
|
|
}
|
2014-02-12 05:23:40 -05:00
|
|
|
signUpDate : {type : Date, default: () -> new Date() }
|
|
|
|
lastLoggedIn : {type : Date}
|
2018-09-04 12:26:15 -04:00
|
|
|
lastLoginIp : {type : String, default : ''}
|
2014-02-12 05:23:40 -05:00
|
|
|
loginCount : {type : Number, default: 0}
|
|
|
|
holdingAccount : {type : Boolean, default: false}
|
|
|
|
ace : {
|
2018-05-10 13:03:54 -04:00
|
|
|
mode : {type : String, default: 'none'}
|
|
|
|
theme : {type : String, default: 'textmate'}
|
2018-08-28 05:10:16 -04:00
|
|
|
overallTheme : {type: String, default: "" }
|
2018-05-10 13:03:54 -04:00
|
|
|
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}
|
2018-03-28 12:11:41 -04:00
|
|
|
}
|
2014-02-12 05:23:40 -05:00
|
|
|
features : {
|
2018-03-28 12:11:41 -04:00
|
|
|
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 }
|
2018-11-14 06:08:15 -05:00
|
|
|
gitBridge: { type:Boolean, default: Settings.defaultFeatures.gitBridge }
|
2018-03-28 12:11:41 -04:00
|
|
|
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 }
|
2018-11-30 08:03:35 -05:00
|
|
|
zotero: { type:Boolean, default: Settings.defaultFeatures.zotero }
|
2018-03-28 12:11:41 -04:00
|
|
|
referencesSearch: { type:Boolean, default: Settings.defaultFeatures.referencesSearch }
|
|
|
|
}
|
2019-04-17 10:00:13 -04:00
|
|
|
must_reconfirm:{ type:Boolean, default: false }
|
2014-02-12 05:23:40 -05:00
|
|
|
referal_id : {type:String, default:() -> uuid.v4().split("-")[0]}
|
|
|
|
refered_users: [ type:ObjectId, ref:'User' ]
|
|
|
|
refered_user_count: { type:Number, default: 0 }
|
2016-04-01 06:36:19 -04:00
|
|
|
refProviders: {
|
|
|
|
mendeley: Boolean # coerce the refProviders values to Booleans
|
|
|
|
zotero: Boolean
|
|
|
|
}
|
2016-06-06 08:12:24 -04:00
|
|
|
betaProgram: { type:Boolean, default: false}
|
2017-08-07 06:24:04 -04:00
|
|
|
overleaf:
|
|
|
|
id: { type: Number }
|
|
|
|
accessToken: { type: String }
|
2017-08-09 05:50:05 -04:00
|
|
|
refreshToken: { type: String }
|
2018-01-26 11:44:14 -05:00
|
|
|
awareOfV2: { type:Boolean, default: false }
|
2019-05-14 05:26:51 -04:00
|
|
|
thirdPartyIdentifiers: { type: Array, default: [] }
|
2019-05-16 06:11:42 -04:00
|
|
|
migratedAt: { type: Date }
|
2014-02-12 05:23:40 -05:00
|
|
|
|
2017-11-22 08:37:57 -05:00
|
|
|
conn = mongoose.createConnection(Settings.mongo.url, {
|
|
|
|
server: {poolSize: Settings.mongo.poolSize || 10},
|
|
|
|
config: {autoIndex: false}
|
|
|
|
})
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
User = conn.model('User', UserSchema)
|
|
|
|
|
|
|
|
model = mongoose.model 'User', UserSchema
|
|
|
|
exports.User = User
|