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)
{
});
},
+ getByName: function(names, cb) {
+ db.serialize(function() {
+ const query =
+ "SELECT id " +
+ "FROM Users " +
+ "WHERE name IN ('" + names.join("','") + "')";
+ db.all(query, cb);
+ });
+ },
+
/////////
// MODIFY
db.run(query, cb);
});
},
+
+ /////////////////
+ // NOTIFICATIONS
+
+ tryNotify: function(oppId, gid, vname, message)
+ {
+ // TODO: send email to oppId (request...) with title
+ // "vchess.club - vname" and content "message"
+ }
}
module.exports = UserModel;