From b57e1d48e6e28533e0e7ee2ef2fa673c84180726 Mon Sep 17 00:00:00 2001 From: knotteye Date: Sat, 27 Jun 2020 10:21:00 -0500 Subject: [PATCH] Fix bug where the profile page wouldn't set record flag. --- src/http.ts | 6 +++++- templates/profile.njk | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/http.ts b/src/http.ts index 6a46094..44d91a8 100644 --- a/src/http.ts +++ b/src/http.ts @@ -164,6 +164,8 @@ async function initAPI() { app.post('/api/user/update', (req, res) => { validToken(req.cookies.Authorization).then((t) => { if(t) { + if(req.body.record === "true") req.body.record = true; + else if(req.body.record === "false") req.body.record = false; return api.update({name: t['username'], title: "title" in req.body ? req.body.title : false, bio: "bio" in req.body ? req.body.bio : false, @@ -377,7 +379,9 @@ async function initSite(openReg) { app.get('/profile', (req, res) => { if(tryDecode(req.cookies.Authorization)) { db.query('select * from user_meta where username='+db.raw.escape(JWT.decode(req.cookies.Authorization)['username'])).then((result) => { - res.render('profile.njk', Object.assign({meta: result[0]}, {auth: {is: true, name: JWT.decode(req.cookies.Authorization)['username']}}, njkconf)); + db.query('select record_flag from users where username='+db.raw.escape(JWT.decode(req.cookies.Authorization)['username'])).then((r2) => { + res.render('profile.njk', Object.assign({rflag: r2[0]}, {meta: result[0]}, {auth: {is: true, name: JWT.decode(req.cookies.Authorization)['username']}}, njkconf)); + }); }); //res.render('profile.njk', Object.assign({auth: {is: true, name: JWT.decode(req.cookies.Authorization)['username']}}, njkconf)); } diff --git a/templates/profile.njk b/templates/profile.njk index 3daebce..a520de5 100644 --- a/templates/profile.njk +++ b/templates/profile.njk @@ -5,7 +5,7 @@
Stream Title:

Bio:

- Record VODs: Yes No

+ Record VODs: Yes No