Small Updates (#10701)

* small updates

* fix client unit test

* fix uuid validation
This commit is contained in:
Matteo Pagliazzi
2018-09-20 15:01:12 +02:00
committed by GitHub
parent 33a8072d23
commit dd7fa73961
13 changed files with 1238 additions and 636 deletions

1732
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,13 +10,13 @@
"amplitude": "^3.5.0", "amplitude": "^3.5.0",
"apidoc": "^0.17.5", "apidoc": "^0.17.5",
"apn": "^2.2.0", "apn": "^2.2.0",
"autoprefixer": "^8.5.0", "autoprefixer": "^8.6.5",
"aws-sdk": "^2.239.1", "aws-sdk": "^2.317.0",
"axios": "^0.18.0", "axios": "^0.18.0",
"axios-progress-bar": "^1.2.0", "axios-progress-bar": "^1.2.0",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-eslint": "^8.2.3", "babel-eslint": "^8.2.6",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.5",
"babel-plugin-syntax-async-functions": "^6.13.0", "babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
@@ -28,46 +28,46 @@
"babel-runtime": "^6.11.6", "babel-runtime": "^6.11.6",
"bcrypt": "github:MylesBorins/node.bcrypt.js#update-nan", "bcrypt": "github:MylesBorins/node.bcrypt.js#update-nan",
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
"bootstrap": "^4.1.1", "bootstrap": "^4.1.3",
"bootstrap-vue": "^2.0.0-rc.9", "bootstrap-vue": "^2.0.0-rc.9",
"compression": "^1.7.2", "compression": "^1.7.3",
"cookie-session": "^1.2.0", "cookie-session": "^1.2.0",
"coupon-code": "^0.4.5", "coupon-code": "^0.4.5",
"cross-env": "^5.1.5", "cross-env": "^5.2.0",
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"csv-stringify": "^3.0.0", "csv-stringify": "^3.0.0",
"cwait": "^1.1.1", "cwait": "^1.1.1",
"domain-middleware": "~0.1.0", "domain-middleware": "~0.1.0",
"express": "^4.16.3", "express": "^4.16.3",
"express-basic-auth": "^1.1.5", "express-basic-auth": "^1.1.5",
"express-validator": "^5.2.0", "express-validator": "^5.3.0",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
"glob": "^7.1.2", "glob": "^7.1.3",
"got": "^9.0.0", "got": "^9.2.2",
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-babel": "^7.0.1", "gulp-babel": "^7.0.1",
"gulp-imagemin": "^4.1.0", "gulp-imagemin": "^4.1.0",
"gulp-nodemon": "^2.2.1", "gulp-nodemon": "^2.2.1",
"gulp.spritesmith": "^6.9.0", "gulp.spritesmith": "^6.9.0",
"habitica-markdown": "^1.3.0", "habitica-markdown": "^1.3.0",
"hellojs": "^1.15.1", "hellojs": "^1.17.1",
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"image-size": "^0.6.2", "image-size": "^0.6.3",
"in-app-purchase": "^1.9.4", "in-app-purchase": "^1.10.1",
"intro.js": "^2.9.3", "intro.js": "^2.9.3",
"jquery": ">=3.0.0", "jquery": ">=3.0.0",
"js2xmlparser": "^3.0.0", "js2xmlparser": "^3.0.0",
"lodash": "^4.17.10", "lodash": "^4.17.11",
"merge-stream": "^1.0.0", "merge-stream": "^1.0.0",
"method-override": "^2.3.5", "method-override": "^2.3.5",
"moment": "^2.22.1", "moment": "^2.22.1",
"moment-recur": "^1.0.7", "moment-recur": "^1.0.7",
"mongoose": "^5.1.2", "mongoose": "^5.2.15",
"morgan": "^1.7.0", "morgan": "^1.9.1",
"nconf": "^0.10.0", "nconf": "^0.10.0",
"node-gcm": "^0.14.4", "node-gcm": "^0.14.4",
"node-sass": "^4.9.0", "node-sass": "^4.9.3",
"nodemailer": "^4.6.4", "nodemailer": "^4.6.8",
"ora": "^2.1.0", "ora": "^2.1.0",
"pageres": "^4.1.1", "pageres": "^4.1.1",
"passport": "^0.4.0", "passport": "^0.4.0",
@@ -75,41 +75,41 @@
"passport-google-oauth20": "1.0.0", "passport-google-oauth20": "1.0.0",
"paypal-ipn": "3.0.0", "paypal-ipn": "3.0.0",
"paypal-rest-sdk": "^1.8.1", "paypal-rest-sdk": "^1.8.1",
"popper.js": "^1.14.3", "popper.js": "^1.14.4",
"postcss-easy-import": "^3.0.0", "postcss-easy-import": "^3.0.0",
"ps-tree": "^1.0.0", "ps-tree": "^1.0.0",
"pug": "^2.0.3", "pug": "^2.0.3",
"pusher": "^1.3.0", "pusher": "^1.3.0",
"rimraf": "^2.4.3", "rimraf": "^2.4.3",
"sass-loader": "^7.0.0", "sass-loader": "^7.1.0",
"shelljs": "^0.8.2", "shelljs": "^0.8.2",
"smartbanner.js": "^1.9.1", "smartbanner.js": "^1.9.1",
"stripe": "^5.9.0", "stripe": "^5.9.0",
"superagent": "^3.8.3", "superagent": "^3.8.3",
"svg-inline-loader": "^0.8.0", "svg-inline-loader": "^0.8.0",
"svg-url-loader": "^2.3.2", "svg-url-loader": "^2.3.2",
"svgo": "^1.0.5", "svgo": "^1.1.1",
"svgo-loader": "^2.1.0", "svgo-loader": "^2.2.0",
"universal-analytics": "^0.4.16", "universal-analytics": "^0.4.17",
"update": "^0.7.4", "update": "^0.7.4",
"upgrade": "^1.1.0", "upgrade": "^1.1.0",
"url-loader": "^1.0.0", "url-loader": "^1.1.1",
"useragent": "^2.1.9", "useragent": "^2.1.9",
"uuid": "^3.0.1", "uuid": "^3.3.2",
"validator": "^10.5.0", "validator": "^10.7.1",
"vinyl-buffer": "^1.0.1", "vinyl-buffer": "^1.0.1",
"vue": "^2.5.16", "vue": "^2.5.17",
"vue-loader": "^14.2.2", "vue-loader": "^14.2.2",
"vue-mugen-scroll": "^0.2.1", "vue-mugen-scroll": "^0.2.1",
"vue-router": "^3.0.0", "vue-router": "^3.0.0",
"vue-style-loader": "^4.1.0", "vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.5.16", "vue-template-compiler": "^2.5.17",
"vuedraggable": "^2.15.0", "vuedraggable": "^2.15.0",
"vuejs-datepicker": "git://github.com/habitrpg/vuejs-datepicker.git#5d237615463a84a23dd6f3f77c6ab577d68593ec", "vuejs-datepicker": "git://github.com/habitrpg/vuejs-datepicker.git#5d237615463a84a23dd6f3f77c6ab577d68593ec",
"webpack": "^3.12.0", "webpack": "^3.12.0",
"webpack-merge": "^4.0.0", "webpack-merge": "^4.1.4",
"winston": "^2.4.2", "winston": "^2.4.4",
"winston-loggly-bulk": "^2.0.2", "winston-loggly-bulk": "^2.0.3",
"xml2js": "^0.4.4" "xml2js": "^0.4.4"
}, },
"private": true, "private": true,
@@ -144,22 +144,22 @@
"apidoc": "gulp apidoc" "apidoc": "gulp apidoc"
}, },
"devDependencies": { "devDependencies": {
"@vue/test-utils": "^1.0.0-beta.16", "@vue/test-utils": "^1.0.0-beta.25",
"babel-plugin-istanbul": "^4.1.6", "babel-plugin-istanbul": "^4.1.6",
"babel-plugin-syntax-object-rest-spread": "^6.13.0", "babel-plugin-syntax-object-rest-spread": "^6.13.0",
"chai": "^4.1.2", "chai": "^4.1.2",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"chalk": "^2.4.1", "chalk": "^2.4.1",
"chromedriver": "^2.38.3", "chromedriver": "^2.41.0",
"connect-history-api-fallback": "^1.1.0", "connect-history-api-fallback": "^1.1.0",
"coveralls": "^3.0.1", "coveralls": "^3.0.2",
"cross-spawn": "^6.0.5", "cross-spawn": "^6.0.5",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-habitrpg": "^4.0.0", "eslint-config-habitrpg": "^4.0.0",
"eslint-friendly-formatter": "^4.0.1", "eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.0.0", "eslint-loader": "^2.1.0",
"eslint-plugin-html": "^4.0.3", "eslint-plugin-html": "^4.0.5",
"eslint-plugin-mocha": "^5.0.0", "eslint-plugin-mocha": "^5.2.0",
"eventsource-polyfill": "^0.9.6", "eventsource-polyfill": "^0.9.6",
"expect.js": "^0.3.1", "expect.js": "^0.3.1",
"http-proxy-middleware": "^0.18.0", "http-proxy-middleware": "^0.18.0",
@@ -175,20 +175,20 @@
"karma-sinon-stub-promise": "^1.0.0", "karma-sinon-stub-promise": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.32", "karma-spec-reporter": "0.0.32",
"karma-webpack": "^3.0.0", "karma-webpack": "^3.0.5",
"lcov-result-merger": "^3.0.0", "lcov-result-merger": "^3.0.0",
"mocha": "^5.1.1", "mocha": "^5.1.1",
"monk": "^6.0.6", "monk": "^6.0.6",
"nightwatch": "^0.9.21", "nightwatch": "^0.9.21",
"puppeteer": "^1.4.0", "puppeteer": "^1.8.0",
"require-again": "^2.0.0", "require-again": "^2.0.0",
"selenium-server": "^3.12.0", "selenium-server": "^3.14.0",
"sinon": "^4.5.0", "sinon": "^4.5.0",
"sinon-chai": "^3.0.0", "sinon-chai": "^3.2.0",
"sinon-stub-promise": "^4.0.0", "sinon-stub-promise": "^4.0.0",
"webpack-bundle-analyzer": "^2.12.0", "webpack-bundle-analyzer": "^2.12.0",
"webpack-dev-middleware": "^2.0.5", "webpack-dev-middleware": "^2.0.5",
"webpack-hot-middleware": "^2.22.2" "webpack-hot-middleware": "^2.24.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"memwatch-next": "^0.3.0", "memwatch-next": "^0.3.0",

View File

@@ -88,7 +88,7 @@ describe('Task Column', () => {
expect(el).to.eq(taskListOverride[i]); expect(el).to.eq(taskListOverride[i]);
}); });
wrapper.setProps({ isUser: false, taskListOverride }); wrapper.setProps({ isUser: false });
wrapper.vm.taskList.forEach((el, i) => { wrapper.vm.taskList.forEach((el, i) => {
expect(el).to.eq(taskListOverride[i]); expect(el).to.eq(taskListOverride[i]);

View File

@@ -8,7 +8,7 @@ module.exports = function baseModel (schema, options = {}) {
_id: { _id: {
type: String, type: String,
default: uuid, default: uuid,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
}, },
}); });
} }

View File

@@ -31,8 +31,8 @@ let schema = new Schema({
todos: [{type: String, ref: 'Task'}], todos: [{type: String, ref: 'Task'}],
rewards: [{type: String, ref: 'Task'}], rewards: [{type: String, ref: 'Task'}],
}, },
leader: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.'], required: true}, leader: {type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.'], required: true},
group: {type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.'], required: true}, group: {type: String, ref: 'Group', validate: [(v) => validator.isUUID(v), 'Invalid uuid.'], required: true},
memberCount: {type: Number, default: 0}, memberCount: {type: Number, default: 0},
prize: {type: Number, default: 0, min: 0}, prize: {type: Number, default: 0, min: 0},
categories: [{ categories: [{

View File

@@ -69,7 +69,7 @@ export let schema = new Schema({
name: {type: String, required: true}, name: {type: String, required: true},
summary: {type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS}, summary: {type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS},
description: String, description: String,
leader: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.'], required: true}, leader: {type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.'], required: true},
type: {type: String, enum: ['guild', 'party'], required: true}, type: {type: String, enum: ['guild', 'party'], required: true},
privacy: {type: String, enum: ['private', 'public'], default: 'private', required: true}, privacy: {type: String, enum: ['private', 'public'], default: 'private', required: true},
chat: Array, chat: Array,

View File

@@ -7,7 +7,7 @@ const Schema = mongoose.Schema;
export let schema = new Schema({ export let schema = new Schema({
_id: {type: String, required: true}, // Use a custom string as _id _id: {type: String, required: true}, // Use a custom string as _id
consumed: {type: Boolean, default: false, required: true}, consumed: {type: Boolean, default: false, required: true},
userId: {type: String, ref: 'User', required: true, validate: [validator.isUUID, 'Invalid uuid.']}, userId: {type: String, ref: 'User', required: true, validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
}, { }, {
strict: true, strict: true,
minimize: false, // So empty objects are returned minimize: false, // So empty objects are returned

View File

@@ -5,7 +5,7 @@ import validator from 'validator';
export let schema = new mongoose.Schema({ export let schema = new mongoose.Schema({
planId: String, planId: String,
subscriptionId: String, subscriptionId: String,
owner: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, owner: {type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
quantity: {type: Number, default: 1}, quantity: {type: Number, default: 1},
paymentMethod: String, // enum: ['Paypal', 'Stripe', 'Gift', 'Amazon Payments', 'Google', '']} paymentMethod: String, // enum: ['Paypal', 'Stripe', 'Gift', 'Amazon Payments', 'Google', '']}
customerId: String, // Billing Agreement Id in case of Amazon Payments customerId: String, // Billing Agreement Id in case of Amazon Payments

View File

@@ -9,7 +9,7 @@ export let schema = new Schema({
id: { id: {
type: String, type: String,
default: uuid, default: uuid,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
required: true, required: true,
}, },
name: {type: String, required: true}, name: {type: String, required: true},

View File

@@ -76,7 +76,7 @@ export let TaskSchema = new Schema({
}, },
tags: [{ tags: [{
type: String, type: String,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
}], }],
value: {type: Number, default: 0, required: true}, // redness or cost for rewards Required because it must be settable (for rewards) value: {type: Number, default: 0, required: true}, // redness or cost for rewards Required because it must be settable (for rewards)
priority: { priority: {
@@ -89,26 +89,26 @@ export let TaskSchema = new Schema({
], ],
}, },
attribute: {type: String, default: 'str', enum: ['str', 'con', 'int', 'per']}, attribute: {type: String, default: 'str', enum: ['str', 'con', 'int', 'per']},
userId: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set it belongs to a challenge userId: {type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}, // When not set it belongs to a challenge
challenge: { challenge: {
shortName: {type: String}, shortName: {type: String},
id: {type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}, // When set (and userId not set) it's the original task id: {type: String, ref: 'Challenge', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}, // When set (and userId not set) it's the original task
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task taskId: {type: String, ref: 'Task', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task
broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration
winner: String, // user.profile.name of the winner winner: String, // user.profile.name of the winner
}, },
group: { group: {
id: {type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.']}, id: {type: String, ref: 'Group', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
broken: {type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED']}, broken: {type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED']},
assignedUsers: [{type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}], assignedUsers: [{type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}],
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']}, taskId: {type: String, ref: 'Task', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
approval: { approval: {
required: {type: Boolean, default: false}, required: {type: Boolean, default: false},
approved: {type: Boolean, default: false}, approved: {type: Boolean, default: false},
dateApproved: {type: Date}, dateApproved: {type: Date},
approvingUser: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, approvingUser: {type: String, ref: 'User', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
requested: {type: Boolean, default: false}, requested: {type: Boolean, default: false},
requestedDate: {type: Date}, requestedDate: {type: Date},
}, },
@@ -117,7 +117,7 @@ export let TaskSchema = new Schema({
reminders: [{ reminders: [{
_id: false, _id: false,
id: {type: String, validate: [validator.isUUID, 'Invalid uuid.'], default: shared.uuid, required: true}, id: {type: String, validate: [(v) => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
startDate: {type: Date}, startDate: {type: Date},
time: {type: Date, required: true}, time: {type: Date, required: true},
}], }],
@@ -261,7 +261,7 @@ let dailyTodoSchema = () => {
completed: {type: Boolean, default: false}, completed: {type: Boolean, default: false},
text: {type: String, required: false, default: ''}, // required:false because it can be empty on creation text: {type: String, required: false, default: ''}, // required:false because it can be empty on creation
_id: false, _id: false,
id: {type: String, default: shared.uuid, required: true, validate: [validator.isUUID, 'Invalid uuid.']}, id: {type: String, default: shared.uuid, required: true, validate: [(v) => validator.isUUID(v), 'Invalid uuid.']},
linkId: {type: String}, linkId: {type: String},
}], }],
}; };

View File

@@ -373,7 +373,7 @@ let schema = new Schema({
return {}; return {};
}}, }},
challenges: [{type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}], challenges: [{type: String, ref: 'Challenge', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}],
invitations: { invitations: {
// Using an array without validation because otherwise mongoose treat this as a subdocument and applies _id by default // Using an array without validation because otherwise mongoose treat this as a subdocument and applies _id by default
@@ -390,7 +390,7 @@ let schema = new Schema({
type: String, type: String,
ref: 'Group', ref: 'Group',
required: true, required: true,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
}, },
name: { name: {
type: String, type: String,
@@ -400,15 +400,15 @@ let schema = new Schema({
type: String, type: String,
ref: 'User', ref: 'User',
required: true, required: true,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
}, },
}], }],
}, },
guilds: [{type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.']}], guilds: [{type: String, ref: 'Group', validate: [(v) => validator.isUUID(v), 'Invalid uuid.']}],
party: { party: {
_id: {type: String, validate: [validator.isUUID, 'Invalid uuid.'], ref: 'Group'}, _id: {type: String, validate: [(v) => validator.isUUID(v), 'Invalid uuid.'], ref: 'Group'},
order: {type: String, default: 'level'}, order: {type: String, default: 'level'},
orderAscending: {type: String, default: 'ascending'}, orderAscending: {type: String, default: 'ascending'},
quest: { quest: {

View File

@@ -39,7 +39,7 @@ export let schema = new Schema({
id: { id: {
type: String, type: String,
default: uuid, default: uuid,
validate: [validator.isUUID, 'Invalid uuid.'], validate: [(v) => validator.isUUID(v), 'Invalid uuid.'],
// @TODO: Add these back once we figure out the issue with notifications // @TODO: Add these back once we figure out the issue with notifications
// See Fix for https://github.com/HabitRPG/habitica/issues/9923 // See Fix for https://github.com/HabitRPG/habitica/issues/9923
// required: true, // required: true,

View File

@@ -34,7 +34,7 @@ export let schema = new Schema({
id: { id: {
type: String, type: String,
required: true, required: true,
validate: [validator.isUUID, shared.i18n.t('invalidWebhookId')], validate: [(v) => validator.isUUID(v), shared.i18n.t('invalidWebhookId')],
default: uuid, default: uuid,
}, },
type: { type: {