X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fmodels%2FUser.js;h=cf4c5293178a72707cbaa7f15e5bdd4b624e38d7;hp=a36ab683487fd7d9d6bc8761ee105536e0c9ca42;hb=98db2082fd31e7a7bc0348e31ce119f39dbc31b3;hpb=98f3902b0f3c4370b07d534f5fcbca146a7a651d diff --git a/server/models/User.js b/server/models/User.js index a36ab683..cf4c5293 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -16,6 +16,24 @@ var params = require("../config/parameters"); const UserModel = { + checkNameEmail: function(o) + { + if (typeof o.name === "string") + { + if (o.name.length == 0) + return "Empty name"; + if (!o.name.match(/^[\w]+$/)) + return "Bad characters in name"; + } + if (typeof o.email === "string") + { + if (o.email.length == 0) + return "Empty email"; + if (!o.email.match(/^[\w.+-]+@[\w.+-]+$/)) + return "Bad characters in email"; + } + }, + // NOTE: parameters are already cleaned (in controller), thus no sanitization here create: function(name, email, notify, callback) {