From 8dfef7634ee84eb731461058bb1785f8cf472564 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 15 Sep 2022 17:49:40 +0200 Subject: Add checkbox for mail notifications on signup page. --- server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index bda099a..7e63528 100644 --- a/server.js +++ b/server.js @@ -263,7 +263,7 @@ const SQL_BLACKLIST_MAIL = SQL("SELECT EXISTS ( SELECT 1 FROM blacklist_mail WHE const SQL_EXISTS_USER_NAME = SQL("SELECT EXISTS ( SELECT 1 FROM users WHERE name=? )").pluck() const SQL_EXISTS_USER_MAIL = SQL("SELECT EXISTS ( SELECT 1 FROM users WHERE mail=? )").pluck() -const SQL_INSERT_USER = SQL("INSERT INTO users (name,mail,password,salt) VALUES (?,?,?,?) RETURNING user_id,name,mail,notify") +const SQL_INSERT_USER = SQL("INSERT INTO users (name,mail,password,salt,notify) VALUES (?,?,?,?,?) RETURNING user_id,name,mail,notify") const SQL_SELECT_USER_BY_NAME = SQL("SELECT * FROM user_view WHERE name=?") const SQL_SELECT_LOGIN_BY_MAIL = SQL("SELECT * FROM user_login_view WHERE mail=?") @@ -451,6 +451,7 @@ app.post('/signup', function (req, res) { let name = req.body.username let mail = req.body.mail let password = req.body.password + let notify = req.body.notify === 'true' name = clean_user_name(name) if (!is_valid_user_name(name)) return err("Invalid user name!") @@ -466,7 +467,7 @@ app.post('/signup', function (req, res) { return err("Password is too long!") let salt = crypto.randomBytes(32).toString('hex') let hash = hash_password(password, salt) - let user = SQL_INSERT_USER.get(name, mail, hash, salt) + let user = SQL_INSERT_USER.get(name, mail, hash, salt, notify ? 1 : 0) login_insert(res, user.user_id) res.redirect('/profile') }) -- cgit v1.2.3