Started work on site-wide toke command management & errorHandler
This commit is contained in:
parent
d516fed309
commit
af7f4219a5
12 changed files with 146 additions and 11 deletions
|
|
@ -20,13 +20,13 @@ const { check, body, checkSchema, checkExact} = require('express-validator');
|
|||
//local imports
|
||||
const {isRank} = require('./permissionsValidator');
|
||||
|
||||
module.exports.accountValidator = {
|
||||
module.exports = {
|
||||
user: (field = 'user') => body(field).escape().trim().isLength({min: 1, max: 22}),
|
||||
|
||||
//Password security requirements may change over time, therefore we should only validate against strongPassword() when creating new accounts
|
||||
//that way we don't break old ones upon change
|
||||
pass: (field = 'pass') => body(field).notEmpty().escape().trim(),
|
||||
securePass: (field) => module.exports.accountValidator.pass(field).isStrongPassword({minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1}),
|
||||
securePass: (field) => module.exports.pass(field).isStrongPassword({minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1}),
|
||||
|
||||
email: (field = 'email') => body(field).optional().isEmail().normalizeEmail(),
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const { check, body, checkSchema, checkExact} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {accountValidator} = require('./accountValidator');
|
||||
const accountValidator = require('./accountValidator');
|
||||
|
||||
module.exports.channelValidator = {
|
||||
module.exports = {
|
||||
name: (field = 'name') => check(field).escape().trim().isLength({min: 1, max: 50}),
|
||||
|
||||
description: (field = 'description') => body(field).escape().trim().isLength({min: 1, max: 1000}),
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ module.exports.permissionsValidator = {
|
|||
options: module.exports.isRank
|
||||
},
|
||||
},
|
||||
'permissionsMap.editTokeCommands': {
|
||||
optional: true,
|
||||
custom: {
|
||||
options: module.exports.isRank
|
||||
}
|
||||
},
|
||||
'permissionsMap.banUser': {
|
||||
optional: true,
|
||||
custom: {
|
||||
|
|
|
|||
22
src/validators/tokebotValidator.js
Normal file
22
src/validators/tokebotValidator.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//NPM Imports
|
||||
const { check } = require('express-validator');
|
||||
|
||||
module.exports = {
|
||||
command: (field = 'command') => check(field).escape().trim().isAlphanumeric().isLength({min: 1, max: 30}),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue