added: _ e - all'username in fase di registrazione

This commit is contained in:
paoloar77
2022-02-14 19:35:11 +01:00
parent c7d52ca531
commit a3502c1d9d
3 changed files with 22 additions and 3 deletions

View File

@@ -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')

View File

@@ -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;

View File

@@ -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 = {};