X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Fmodels%2FUser.js;h=021cadcb32aebf0a3859d3da209b54c09245d011;hb=d9a7a1e40254bda6e545514596a7363048c084f9;hp=5117c17522ed628b525265b4bef1d17be59463d1;hpb=a97bdbda4ecf83645d409b717e36828784d1450d;p=vchess.git diff --git a/server/models/User.js b/server/models/User.js index 5117c175..021cadcb 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -20,8 +20,8 @@ const UserModel = checkNameEmail: function(o) { return ( - (!o.name || o.name.match(/^[\w]+$/)) && - (!o.email || o.email.match(/^[\w.+-]+@[\w.+-]+$/)) + (!o.name || !!(o.name.match(/^[\w-]+$/))) && + (!o.email || !!(o.email.match(/^[\w.+-]+@[\w.+-]+$/))) ); }, @@ -75,6 +75,17 @@ const UserModel = }); }, + setNewsRead: function(uid) + { + db.serialize(function() { + const query = + "UPDATE Users " + + "SET newsRead = " + Date.now() + " " + + "WHERE id = " + uid; + db.run(query); + }); + }, + // Set session token only if empty (first login) // NOTE: weaker security (but avoid to re-login everywhere after each logout) // TODO: option would be to reset all tokens periodically, e.g. every 3 months @@ -118,7 +129,7 @@ const UserModel = notify: function(user, message) { const subject = "vchess.club - notification"; - const body = "Hello " + user.name + "!" + ` + const body = "Hello " + user.name + " !" + ` ` + message; sendEmail(params.mail.noreply, user.email, subject, body); },