codecombat/server/users/user_schema.coffee
Sébastien Moratinos 729cd300b7 server reorganize files and folder by features
- move and rename files
- use associative arrays which store handlers for 'dynamically'
  load module from de db route
- store models_path in test/server/common,
  a global model variable has the same name that the filename of the model
2014-01-23 01:01:40 +01:00

50 lines
2 KiB
CoffeeScript

c = require '../commons/schemas'
emailSubscriptions = ['announcement', 'tester', 'level_creator', 'developer', 'article_editor', 'translator', 'support', 'notification']
UserSchema = c.object {},
name: c.shortString({title: 'Display Name', default:''})
email: c.shortString({title: 'Email', format: 'email'})
firstName: c.shortString({title: 'First Name'})
lastName: c.shortString({title: 'Last Name'})
gender: {type: 'string', 'enum': ['male', 'female']}
password: {type: 'string', maxLength: 256, minLength: 2, title:'Password'}
passwordReset: {type: 'string'}
photoURL: {type: 'string', format: 'url', required: false}
facebookID: c.shortString({title: 'Facebook ID'})
gplusID: c.shortString({title: 'G+ ID'})
wizardColor1: c.pct({title: 'Wizard Clothes Color'})
volume: c.pct({title: 'Volume'})
music: {type: 'boolean', default: true}
#autocastDelay, or more complex autocast options? I guess I'll see what I need when trying to hook up Scott's suggested autocast behavior
emailSubscriptions: c.array {uniqueItems: true, 'default': ['announcement']}, {'enum': emailSubscriptions}
# server controlled
permissions: c.array {'default': []}, c.shortString()
dateCreated: c.date({title: 'Date Joined'})
anonymous: {type: 'boolean', 'default': true}
testGroupNumber: {type: 'integer', minimum: 0, maximum: 256, exclusiveMaximum: true}
mailChimp: {type: 'object'}
hourOfCode: {type: 'boolean'}
hourOfCodeComplete: {type: 'boolean'}
emailLower: c.shortString()
nameLower: c.shortString()
passwordHash: {type: 'string', maxLength: 256}
# client side
#gravatarProfile: {} (should only ever be kept locally)
emailHash: {type: 'string'}
#Internationalization stuff
preferredLanguage: {type: 'string', default: 'en', 'enum': c.getLanguageCodeArray()}
signedCLA: c.date({title: 'Date Signed the CLA'})
wizard: c.object {},
colorConfig: c.object {additionalProperties: c.colorConfig()}
c.extendBasicProperties UserSchema, 'user'
module.exports = UserSchema