Centralizes list of system classes into Schema
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// An object that encapsulates everything we need to run a 'find'
|
||||
// operation, encoded in the REST API format.
|
||||
|
||||
var Schema = require('./Schema');
|
||||
var Parse = require('parse/node').Parse;
|
||||
|
||||
import { default as FilesController } from './Controllers/FilesController';
|
||||
@@ -171,7 +172,7 @@ RestQuery.prototype.redirectClassNameForKey = function() {
|
||||
|
||||
// Validates this operation against the allowClientClassCreation config.
|
||||
RestQuery.prototype.validateClientClassCreation = function() {
|
||||
let sysClass = ['_User', '_Installation', '_Role', '_Session', '_Product'];
|
||||
let sysClass = Schema.systemClasses;
|
||||
if (this.config.allowClientClassCreation === false && !this.auth.isMaster
|
||||
&& sysClass.indexOf(this.className) === -1) {
|
||||
return this.config.database.collectionExists(this.className).then((hasClass) => {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// This could be either a "create" or an "update".
|
||||
|
||||
import cache from './cache';
|
||||
var Schema = require('./Schema');
|
||||
var deepcopy = require('deepcopy');
|
||||
|
||||
var Auth = require('./Auth');
|
||||
@@ -108,7 +109,7 @@ RestWrite.prototype.getUserAndRoleACL = function() {
|
||||
|
||||
// Validates this operation against the allowClientClassCreation config.
|
||||
RestWrite.prototype.validateClientClassCreation = function() {
|
||||
let sysClass = ['_User', '_Installation', '_Role', '_Session', '_Product'];
|
||||
let sysClass = Schema.systemClasses;
|
||||
if (this.config.allowClientClassCreation === false && !this.auth.isMaster
|
||||
&& sysClass.indexOf(this.className) === -1) {
|
||||
return this.config.database.collectionExists(this.className).then((hasClass) => {
|
||||
|
||||
@@ -68,6 +68,19 @@ var defaultColumns = {
|
||||
"order": {type:'Number'},
|
||||
"title": {type:'String'},
|
||||
"subtitle": {type:'String'},
|
||||
},
|
||||
_PushStatus: {
|
||||
"pushTime": {type:'String'},
|
||||
"source": {type:'String'}, // rest or web
|
||||
"query": {type:'String'}, // the stringified JSON query
|
||||
"payload": {type:'Object'}, // the JSON payload,
|
||||
"title": {type:'String'},
|
||||
"expiry": {type:'Number'},
|
||||
"status": {type:'String'},
|
||||
"numSent": {type:'Number'},
|
||||
"pushHash": {type:'String'},
|
||||
"errorMessage": {type:'Object'},
|
||||
"sentPerType": {type:'Object'}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -76,6 +89,8 @@ var requiredColumns = {
|
||||
_Role: ["name", "ACL"]
|
||||
}
|
||||
|
||||
const systemClasses = ['_User', '_Installation', '_Role', '_Session', '_Product', '_PushStatus'];
|
||||
|
||||
// 10 alpha numberic chars + uppercase
|
||||
const userIdRegex = /^[a-zA-Z0-9]{10}$/;
|
||||
// Anything that start with role
|
||||
@@ -127,13 +142,8 @@ function validateCLP(perms) {
|
||||
var joinClassRegex = /^_Join:[A-Za-z0-9_]+:[A-Za-z0-9_]+/;
|
||||
var classAndFieldRegex = /^[A-Za-z][A-Za-z0-9_]*$/;
|
||||
function classNameIsValid(className) {
|
||||
return (
|
||||
className === '_User' ||
|
||||
className === '_Installation' ||
|
||||
className === '_Session' ||
|
||||
return (systemClasses.indexOf(className) > -1 ||
|
||||
className === '_SCHEMA' || //TODO: remove this, as _SCHEMA is not a valid class name for storing Parse Objects.
|
||||
className === '_Role' ||
|
||||
className === '_Product' ||
|
||||
joinClassRegex.test(className) ||
|
||||
//Class names have the same constraints as field names, but also allow the previous additional names.
|
||||
fieldNameIsValid(className)
|
||||
@@ -903,4 +913,5 @@ module.exports = {
|
||||
buildMergedSchemaObject: buildMergedSchemaObject,
|
||||
mongoFieldTypeToSchemaAPIType: mongoFieldTypeToSchemaAPIType,
|
||||
mongoSchemaToSchemaAPIResponse,
|
||||
systemClasses,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user