projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cosmetics
[vchess.git]
/
server
/
models
/
User.js
diff --git
a/server/models/User.js
b/server/models/User.js
index
f3adb31
..
9b3049b
100644
(file)
--- a/
server/models/User.js
+++ b/
server/models/User.js
@@
-20,8
+20,8
@@
const UserModel =
checkNameEmail: function(o)
{
return (
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.+-]+$/)
))
);
},
);
},
@@
-118,7
+118,7
@@
const UserModel =
notify: function(user, message)
{
const subject = "vchess.club - notification";
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);
},
` + message;
sendEmail(params.mail.noreply, user.email, subject, body);
},
@@
-141,13
+141,20
@@
const UserModel =
const day = 86400000;
db.serialize(function() {
const query =
const day = 86400000;
db.serialize(function() {
const query =
- "SELECT id, sessionToken, created " +
+ "SELECT id, sessionToken, created
, name, email
" +
"FROM Users";
db.all(query, (err, users) => {
users.forEach(u => {
"FROM Users";
db.all(query, (err, users) => {
users.forEach(u => {
- // Remove unlogged users for >
1 day
+ // Remove unlogged users for >
24h
if (!u.sessionToken && tsNow - u.created > day)
if (!u.sessionToken && tsNow - u.created > day)
+ {
+ notify(
+ u,
+ "Your account has been deleted because " +
+ "you didn't log in for 24h after registration"
+ );
db.run("DELETE FROM Users WHERE id = " + u.id);
db.run("DELETE FROM Users WHERE id = " + u.id);
+ }
});
});
});
});
});
});