Added user schema definition
MODIFY
src/assets/server/rest/v1/schemas/auth/auth-check-eula.json
src/assets/server/rest/v1/schemas/auth/auth-check-eula.json
"type": "object",
"properties": {
"Email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"Tenant": {
"$ref": "common.json#/definitions/authSubdomain"

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-resend-verification-email.json
src/assets/server/rest/v1/schemas/auth/auth-resend-verification-email.json
"type": "object",
"properties": {
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"tenant": {
"$ref": "common.json#/definitions/authSubdomain"

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-reset-password.json
src/assets/server/rest/v1/schemas/auth/auth-reset-password.json
"type": "object",
"properties": {
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"tenant": {
"$ref": "common.json#/definitions/authSubdomain"
"type": "object",
"properties": {
"password": {
- "$ref": "common.json#/definitions/password"
+ "$ref": "user.json#/definitions/password"
},
"repeatPassword": {
- "$ref": "common.json#/definitions/password"
+ "$ref": "user.json#/definitions/password"
}
},
"required": ["password", "repeatPassword"]

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-signin.json
src/assets/server/rest/v1/schemas/auth/auth-signin.json
"type": "object",
"properties": {
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"password": {
- "$ref": "common.json#/definitions/password"
+ "$ref": "user.json#/definitions/password"
},
"acceptEula": {
"$ref": "common.json#/definitions/acceptEula"

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-signon.json
src/assets/server/rest/v1/schemas/auth/auth-signon.json
"type": "object",
"properties": {
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"name": {
- "$ref": "common.json#/definitions/name"
+ "$ref": "user.json#/definitions/name"
},
"firstName": {
- "$ref": "common.json#/definitions/firstName"
+ "$ref": "user.json#/definitions/firstName"
},
"passwords": {
"type": "object",
"properties": {
"password": {
- "$ref": "common.json#/definitions/password"
+ "$ref": "user.json#/definitions/password"
},
"repeatPassword": {
- "$ref": "common.json#/definitions/password"
+ "$ref": "user.json#/definitions/password"
}
}
},

MODIFY
src/assets/server/rest/v1/schemas/auth/auth-verify-email.json
src/assets/server/rest/v1/schemas/auth/auth-verify-email.json
"type": "object",
"properties": {
"Email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"Tenant": {
"$ref": "common.json#/definitions/authSubdomain"

MODIFY
src/assets/server/rest/v1/schemas/common/common.json
src/assets/server/rest/v1/schemas/common/common.json
"pattern": "^$|^([0-9a-fA-F]{24}\\|?)*$",
"sanitize": "mongo"
},
- "name": {
- "type": "string",
- "minLength": 1,
- "maxLength": 100,
- "sanitize": "mongo"
- },
- "firstName": {
- "type": "string",
- "minLength": 1,
- "maxLength": 100,
- "sanitize": "mongo"
- },
- "email": {
- "type": "string",
- "format": "email",
- "sanitize": "mongo"
- },
"authSubdomain": {
"type": "string",
"pattern": "^[a-z0-9]*$",
"type": "boolean",
"sanitize": "mongo"
},
- "password": {
- "type": "string",
- "sanitize": "mongo",
- "pattern": "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!#@:;,<>\/''\\$%\\^&\\*\\.\\?\\-_\\+\\=\\(\\)])(?=.{8,})"
- },
"captcha": {
"type": "string",
"sanitize": "mongo"

MODIFY
src/assets/server/rest/v1/schemas/tenant/tenant-create.json
src/assets/server/rest/v1/schemas/tenant/tenant-create.json
"type": "object",
"properties": {
"name": {
- "$ref": "common.json#/definitions/name"
+ "$ref": "tenant.json#/definitions/name"
},
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"subdomain": {
"$ref": "common.json#/definitions/subdomain"

MODIFY
src/assets/server/rest/v1/schemas/tenant/tenant-update.json
src/assets/server/rest/v1/schemas/tenant/tenant-update.json
"$ref": "common.json#/definitions/name"
},
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"subdomain": {
"$ref": "common.json#/definitions/subdomain"

ADD
src/assets/server/rest/v1/schemas/tenant/tenant.json
+{
+ "id": "tenant.json",
+ "definitions": {
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 100,
+ "sanitize": "mongo"
+ }
+ }
+}

MODIFY
src/assets/server/rest/v1/schemas/user/imported-user-create-req.json
src/assets/server/rest/v1/schemas/user/imported-user-create-req.json
"type": "object",
"properties": {
"email": {
- "$ref": "common.json#/definitions/email"
+ "$ref": "user.json#/definitions/email"
},
"name": {
- "$ref": "common.json#/definitions/name"
+ "$ref": "user.json#/definitions/name"
},
"firstName": {
- "$ref": "common.json#/definitions/firstName"
+ "$ref": "user.json#/definitions/firstName"
},
"password": {
- "type": "string",
- "minLength": 1,
- "maxLength": 150
+ "$ref": "user.json#/definitions/password"
},
"locale": {
- "type": "string"
+ "$ref": "user.json#/definitions/locale"
},
"issuer": {
- "type": "boolean"
+ "$ref": "user.json#/definitions/issuer"
},
"deleted": {
- "type": "boolean"
+ "$ref": "user.json#/definitions/deleted"
},
"role": {
- "type": "string"
+ "$ref": "user.json#/definitions/role"
},
"status": {
- "type": "string"
+ "$ref": "user.json#/definitions/status"
},
"passwordWrongNbrTrials": {
- "type": "number"
+ "$ref": ""
},
"notificationsActive": {
"type": "boolean"
},
"notifications": {
- "type": "object",
- "properties": {
- "sendSessionStarted": {
- "type": "boolean"
- },
- "sendOptimalChargeReached": {
- "type": "boolean"
- },
- "sendEndOfCharge": {
- "type": "boolean"
- },
- "sendEndOfSession": {
- "type": "boolean"
- },
- "sendUserAccountStatusChanged": {
- "type": "boolean"
- },
- "sendNewRegisteredUser": {
- "type": "boolean"
- },
- "sendUnknownUserBadged": {
- "type": "boolean"
- },
- "sendChargingStationStatusError": {
- "type": "boolean"
- },
- "sendChargingStationRegistered": {
- "type": "boolean"
- },
- "sendOcpiPatchStatusError": {
- "type": "boolean"
- },
- "sendSmtpAuthError": {
- "type": "boolean"
- },
- "sendUserAccountInactivity": {
- "type": "boolean"
- },
- "sendPreparingSessionNotStarted": {
- "type": "boolean"
- },
- "sendOfflineChargingStations": {
- "type": "boolean"
- },
- "sendBillingUserSynchronizationFailed": {
- "type": "boolean"
- },
- "sendSessionNotStarted": {
- "type": "boolean"
- },
- "sendCarCatalogSynchronizationFailed": {
- "type": "boolean"
- }
- }
+ "$ref": "user.json#/definitions/notifications"
}
},
"required": [

ADD
src/assets/server/rest/v1/schemas/user/user-create.json
+{
+ "title": "Create one User",
+ "type": "object",
+ "properties": {
+ "name": {
+ "$ref": "tenant.json#/definitions/name"
+ },
+ "email": {
+ "$ref": "user.json#/definitions/email"
+ },
+ "subdomain": {
+ "$ref": "common.json#/definitions/subdomain"
+ },
+ "logo": {
+ "$ref": "common.json#/definitions/logo"
+ },
+ "address": {
+ "$ref": "common.json#/definitions/address"
+ },
+ "components": {
+ "$ref": "tenant-components.json#/definitions/components"
+ }
+ },
+ "required": [
+ "name",
+ "email",
+ "subdomain"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/user/user.json
+{
+ "$id": "user.json",
+ "definitions": {
+ "id": {
+ "$ref": "common.json#/definitions/id"
+ },
+ "name": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 100,
+ "sanitize": "mongo"
+ },
+ "firstName": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 100,
+ "sanitize": "mongo"
+ },
+ "email": {
+ "type": "string",
+ "format": "email",
+ "sanitize": "mongo"
+ },
+ "password": {
+ "type": "string",
+ "sanitize": "mongo",
+ "pattern": "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!#@:;,<>\/''\\$%\\^&\\*\\.\\?\\-_\\+\\=\\(\\)])(?=.{8,})"
+ },
+ "costCenter": {
+ "type": "string"
+ },
+ "iNumber": {
+ "type": "string"
+ },
+ "image": {
+ "type": "string"
+ },
+ "mobile": {
+ "type": "string"
+ },
+ "locale": {
+ "type": "string"
+ },
+ "address": {
+ "$ref": "common.json#/definitions/address"
+ },
+ "passwords": {
+ "password": {
+ "$ref": "#/definitions/password"
+ }
+ },
+ "phone": {
+ "type": "string"
+ },
+ "issuer": {
+ "type": "boolean"
+ },
+ "notificationsActive": {
+ "type": "boolean"
+ },
+ "status": {
+ "type": "string"
+ },
+ "plateID": {
+ "type": "string"
+ },
+ "role": {
+ "type": "string"
+ },
+ "notifications": {
+ "type": "object",
+ "properties": {
+ "sendSessionStarted": {
+ "type": "boolean"
+ },
+ "sendOptimalChargeReached": {
+ "type": "boolean"
+ },
+ "sendEndOfCharge": {
+ "type": "boolean"
+ },
+ "sendEndOfSession": {
+ "type": "boolean"
+ },
+ "sendUserAccountStatusChanged": {
+ "type": "boolean"
+ },
+ "sendSessionNotStarted": {
+ "type": "boolean"
+ },
+ "sendCarCatalogSynchronizationFailed": {
+ "type": "boolean"
+ },
+ "sendUserAccountInactivity": {
+ "type": "boolean"
+ },
+ "sendPreparingSessionNotStarted": {
+ "type": "boolean"
+ },
+ "sendBillingSynchronizationFailed": {
+ "type": "boolean"
+ },
+ "sendBillingPeriodicOperationFailed": {
+ "type": "boolean"
+ },
+ "sendBillingNewInvoice": {
+ "type": "boolean"
+ },
+ "sendNewRegisteredUser": {
+ "type": "boolean"
+ },
+ "sendUnknownUserBadged": {
+ "type": "boolean"
+ },
+ "sendChargingStationStatusError": {
+ "type": "boolean"
+ },
+ "sendChargingStationRegistered": {
+ "type": "boolean"
+ },
+ "sendOcpiPatchStatusError": {
+ "type": "boolean"
+ },
+ "sendSmtpAuthError": {
+ "type": "boolean"
+ },
+ "sendSmtpError": {
+ "type": "boolean"
+ },
+ "sendOfflineChargingStations": {
+ "type": "boolean"
+ },
+ "sendEndUserErrorNotification": {
+ "type": "boolean"
+ },
+ "sendComputeAndApplyChargingProfilesFailed": {
+ "type": "boolean"
+ },
+ "sendAccountVerificationNotification": {
+ "type": "boolean"
+ },
+ "sendAdminAccountVerificationNotification": {
+ "type": "boolean"
+ }
+ }
+ },
+ "deleted": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "passwordWrongNbrTrials": {
+ "type": "number"
+ }
+ }
+}

MODIFY
src/server/rest/v1/validator/SchemaValidator.ts
src/server/rest/v1/validator/SchemaValidator.ts
@@ -19,6 +19,7 @@ export default class SchemaValidator {
private chargingStationSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation.json`, 'utf8'));
private tagSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/tag/tag.json`, 'utf8'));
private transactionSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction.json`, 'utf8'));
+ private userSchema: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/user/user.json`, 'utf8'));
constructor(readonly moduleName: string,
config: {
@@ -44,9 +45,11 @@ export default class SchemaValidator {
this.ajv.addSchema(this.chargingStationSchema);
this.ajv.addSchema(this.tagSchema);
this.ajv.addSchema(this.transactionSchema);
+ this.ajv.addSchema(this.userSchema);
}
public validate(schema: Schema, content: any): void {
+ try {
const fnValidate = this.ajv.compile(schema);
if (!fnValidate(content)) {
if (!fnValidate.errors) {
@@ -73,5 +76,8 @@ export default class SchemaValidator {
detailedMessages: { errors, content, schema }
});
}
+ } catch (e) {
+ console.log(e);
+ }
}
}

Added user schema definition