diff options
| author | Bobby <[email protected]> | 2022-07-18 00:57:36 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-07-18 00:57:36 +0530 |
| commit | b31bd3dbabb57eda3fddfaa7a59e01e73442834f (patch) | |
| tree | 8acf4f7eec348c9d9e143933ff2ad59784233f2e /functions/render.js | |
| parent | 406a35de9d0d37d20123a0a3e961614142c2cf3c (diff) | |
| download | thatcomputerscientist-b31bd3dbabb57eda3fddfaa7a59e01e73442834f.tar.xz thatcomputerscientist-b31bd3dbabb57eda3fddfaa7a59e01e73442834f.zip | |
Change Init to Ghost
Diffstat (limited to 'functions/render.js')
| -rw-r--r-- | functions/render.js | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/functions/render.js b/functions/render.js deleted file mode 100644 index 81c4a3c9..00000000 --- a/functions/render.js +++ /dev/null @@ -1,37 +0,0 @@ -const jwt = require("jsonwebtoken"); -require("dotenv").config(); -const validationString = process.env.AUTHORIZATION_STRING; -function renderRoute(req, res, page, title, protected = false, data = {}) { - res.locals.messages = req.flash(); - let currentDomain = req.get("host").split(".").reverse(); - - // get the ':scheme' from the request header - let scheme = req.headers[":scheme"] || req.headers["x-forwarded-proto"] || req.protocol || "http"; - currentDomain = currentDomain.length < 3 ? currentDomain.reverse().join('.') : currentDomain[1] + "." + currentDomain[0]; - currentDomain = scheme + "://" + currentDomain; - jwt.verify(req.cookies.token, validationString, (err, decoded) => { - if (err) { - res.clearCookie("token"); - if (protected) { - res.redirect("/"); - } else { - res.render(page, { - title: title, - ...data, - domain: currentDomain, - }); - } - } else { - res.render(page, { - title: title, - username: decoded.username, - ...data, - domain: currentDomain, - }); - } - }); -} - -module.exports = { - renderRoute, -}; |
