diff --git a/src/server/populate/populate.js b/src/server/populate/populate.js index 9401a6e..b233131 100644 --- a/src/server/populate/populate.js +++ b/src/server/populate/populate.js @@ -167,7 +167,7 @@ module.exports = { // Contribtypes const {Contribtype} = require('../models/contribtype'); - await this.insertIntoDb_NoDuplicate(abilita, 'contribtypes', Contribtype, 'label') + await this.insertIntoDb_NoDuplicate(false, 'contribtypes', Contribtype, 'label') const {AdType} = require('../models/adtype'); await this.insertIntoDb_NoDuplicate(abilita, 'adtypes', AdType, 'descr') diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index 9e2dda6..5d2da25 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -91,9 +91,10 @@ router.post('/', async (req, res) => { // tools.mylog("LANG PASSATO = " + user.lang, "IDAPP", user.idapp); - if (!tools.isAlphaNumeric(body.username) || body.email.length < 6 || + if (!tools.isAlphaNumericAndSpecialCharacter(body.username) || body.email.length < 6 || body.username.length < 6 || body.password.length < 6) { await tools.snooze(5000); + console.log('Username non valido in Registrazione: ' + body.username); res.status(400). send({code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: ''}); return 1; @@ -895,7 +896,8 @@ async function eseguiDbOp(idapp, mydata, locale) { const globalTables = require('../tools/globalTables'); - const mytablesstr = ['settings', 'users', 'templemail', 'contribtypes']; + //++ Todo: TO FIXIT ! + const mytablesstr = ['settings', 'users', 'templemail', 'contribtypes', 'bots', 'cfgservers']; try { let numrectot = 0; diff --git a/src/server/tools/general.js b/src/server/tools/general.js index ec304ca..368b449 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -2373,6 +2373,23 @@ module.exports = { } return true; }, + + isAlphaNumericAndSpecialCharacter(str) { + let code, i, len; + + for (i = 0, len = str.length; i < len; i++) { + code = str.charCodeAt(i); + if (!(code > 47 && code < 58) && // numeric (0-9) + !(code > 63 && code < 91) && // upper alpha (A-Z) // e @ + (code !== 95) && // _ + (code !== 45) && // - + !(code > 96 && code < 123)) { // lower alpha (a-z) + return false; + } + } + return true; + }, + categorizeQueryString(queryObj) { let query = {}; let order = {};