mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
small cleanup of cloning user schema
This commit is contained in:
parent
e4afeb9b8e
commit
e42971d202
2 changed files with 13 additions and 15 deletions
|
|
@ -2,21 +2,19 @@ content = require './content'
|
|||
moment = require 'moment'
|
||||
_ = require 'lodash'
|
||||
|
||||
userSchema = {
|
||||
balance: 2
|
||||
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
|
||||
items: { itemsEnabled: false, armor: 0, weapon: 0 }
|
||||
tasks: {}
|
||||
habitIds: []
|
||||
dailyIds: []
|
||||
todoIds: []
|
||||
completedIds: []
|
||||
rewardIds: []
|
||||
}
|
||||
|
||||
module.exports.newUserObject = ->
|
||||
module.exports.userSchema = ->
|
||||
# deep clone, else further new users get duplicate objects
|
||||
newUser = _.cloneDeep(userSchema)
|
||||
newUser = _.cloneDeep
|
||||
balance: 2
|
||||
stats: { money: 0, exp: 0, lvl: 1, hp: 50 }
|
||||
items: { itemsEnabled: false, armor: 0, weapon: 0 }
|
||||
tasks: {}
|
||||
habitIds: []
|
||||
dailyIds: []
|
||||
todoIds: []
|
||||
completedIds: []
|
||||
rewardIds: []
|
||||
|
||||
for task in content.defaultTasks
|
||||
guid = task.id = require('racer').uuid()
|
||||
newUser.tasks[guid] = task
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ strategies =
|
|||
options =
|
||||
domain: (if process.env.NODE_ENV == 'production' then 'https://habitrpg.com' else "http://localhost:3000")
|
||||
allowPurl: true
|
||||
schema: require('../app/schema').newUserObject()
|
||||
schema: require('../app/schema').userSchema()
|
||||
|
||||
mongo_store = new MongoStore {url: process.env.NODE_DB_URI}, ->
|
||||
expressApp
|
||||
|
|
|
|||
Loading…
Reference in a new issue