X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Froutes%2Fusers.js;h=389625c1f3d46a3079034d3fd2fe82d10177bc23;hb=d9a7a1e40254bda6e545514596a7363048c084f9;hp=f9f1d86f6c7b3d4743047498d0213b5f65da8cb1;hpb=866842c3c310524c034922870234120ed2a16cbf;p=vchess.git diff --git a/server/routes/users.js b/server/routes/users.js index f9f1d86f..389625c1 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -13,7 +13,12 @@ router.post('/register', access.unlogged, access.ajax, (req,res) => { { UserModel.create(name, email, notify, (err,ret) => { if (err) - res.json({errmsg: "User creation failed. Try again"}); + { + const msg = err.code == "SQLITE_CONSTRAINT" + ? "User name or email already in use" + : "User creation failed. Try again"; + res.json({errmsg: msg}); + } else { const user = { @@ -76,6 +81,12 @@ router.put('/update', access.logged, access.ajax, (req,res) => { } }); +// Special route to update newsRead timestamp: +router.put('/newsread', access.logged, access.ajax, (req,res) => { + UserModel.setNewsRead(req.userId); + res.json({}); +}); + // Authentication-related methods: // to: object user (to who we send an email) @@ -85,7 +96,7 @@ function setAndSendLoginToken(subject, to, res) const token = genToken(params.token.length); UserModel.setLoginToken(token, to.id); const body = - "Hello " + to.name + "!" + ` + "Hello " + to.name + " !" + ` ` + "Access your account here: " + params.siteURL + "/#/authenticate/" + token + `