switched device_name to devices
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
export default class IdValidate {
|
||||
private static id = Joi.string().pattern(new RegExp('[0-9a-f]{24}')).length(24).messages({'string.pattern.base': 'Invalid object id'});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
import IdValidate from './id';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
import IdValidate from './id';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
export default class NoteFieldValidate {
|
||||
private static note_field = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
export default class ParametersValidate {
|
||||
static input (data, parameters, param) { // data to validate, parameters from template, param: 'new', 'change', 'null'(null values are allowed)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
import IdValidate from './id';
|
||||
|
||||
export default class RootValidate { // validate input for root methods
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
|
||||
import IdValidate from './id';
|
||||
import UserValidate from './user';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
import IdValidate from './id';
|
||||
|
||||
// TODO: do not allow a . in the name !!!
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Joi from '@hapi/joi';
|
||||
import Joi from 'joi';
|
||||
import globals from '../../globals';
|
||||
|
||||
import IdValidate from './id';
|
||||
@ -28,12 +28,14 @@ export default class UserValidate { // validate input for user
|
||||
.alphanum()
|
||||
.max(128),
|
||||
|
||||
device_name: Joi.string()
|
||||
.allow('')
|
||||
.max(128),
|
||||
devices: Joi.array()
|
||||
.items(Joi.string()
|
||||
.allow('')
|
||||
.max(128)
|
||||
)
|
||||
};
|
||||
|
||||
private static specialUsernames = ['admin', 'user', 'key', 'new', 'passreset']; // names a user cannot take
|
||||
private static specialUsernames: string[] = ['admin', 'user', 'key', 'new', 'passreset']; // names a user cannot take
|
||||
|
||||
static input (data, param) { // validate input, set param to 'new' to make all attributes required
|
||||
if (param === 'new') {
|
||||
@ -43,7 +45,7 @@ export default class UserValidate { // validate input for user
|
||||
pass: this.user.pass.required(),
|
||||
level: this.user.level.required(),
|
||||
location: this.user.location.required(),
|
||||
device_name: this.user.device_name.required()
|
||||
devices: this.user.devices.required()
|
||||
}).validate(data);
|
||||
}
|
||||
else if (param === 'change') {
|
||||
@ -52,7 +54,7 @@ export default class UserValidate { // validate input for user
|
||||
email: this.user.email,
|
||||
pass: this.user.pass,
|
||||
location: this.user.location,
|
||||
device_name: this.user.device_name
|
||||
devices: this.user.devices
|
||||
}).validate(data);
|
||||
}
|
||||
else if (param === 'changeadmin') {
|
||||
@ -62,7 +64,7 @@ export default class UserValidate { // validate input for user
|
||||
pass: this.user.pass,
|
||||
level: this.user.level,
|
||||
location: this.user.location,
|
||||
device_name: this.user.device_name
|
||||
devices: this.user.devices
|
||||
}).validate(data);
|
||||
}
|
||||
else {
|
||||
@ -78,8 +80,9 @@ export default class UserValidate { // validate input for user
|
||||
email: this.user.email,
|
||||
level: this.user.level,
|
||||
location: this.user.location,
|
||||
device_name: this.user.device_name
|
||||
devices: this.user.devices
|
||||
}).validate(data, {stripUnknown: true});
|
||||
console.log(data);
|
||||
return error !== undefined? null : value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user