mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 16:59:50 +03:00
formatting
This commit is contained in:
@@ -5,12 +5,21 @@ import type { UserType } from 'types';
|
||||
export const SECURITY_SETTINGS_VALIDATOR = new Schema({
|
||||
jwt_secret: [
|
||||
{ required: true, message: 'JWT secret is required' },
|
||||
{ type: 'string', min: 1, max: 64, message: 'JWT secret must be between 1 and 64 characters' }
|
||||
{
|
||||
type: 'string',
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: 'JWT secret must be between 1 and 64 characters'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export const createUniqueUsernameValidator = (users: UserType[]) => ({
|
||||
validator(rule: InternalRuleItem, username: string, callback: (error?: string) => void) {
|
||||
validator(
|
||||
rule: InternalRuleItem,
|
||||
username: string,
|
||||
callback: (error?: string) => void
|
||||
) {
|
||||
if (username && users.find((u) => u.username === username)) {
|
||||
callback('Username already in use');
|
||||
} else {
|
||||
@@ -32,6 +41,11 @@ export const createUserValidator = (users: UserType[], creating: boolean) =>
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: 'Please provide a password' },
|
||||
{ type: 'string', min: 1, max: 64, message: 'Password must be 1-64 characters' }
|
||||
{
|
||||
type: 'string',
|
||||
min: 1,
|
||||
max: 64,
|
||||
message: 'Password must be 1-64 characters'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user