forked from f0ck/f0ckv2
f
This commit is contained in:
@ -221,14 +221,14 @@ export default new class {
|
||||
return next();
|
||||
};
|
||||
|
||||
async loggedin(req, res, next) {
|
||||
if(!req.session) {
|
||||
return res.reply({
|
||||
code: 401,
|
||||
body: "401 - Unauthorized"
|
||||
});
|
||||
}
|
||||
return next();
|
||||
};
|
||||
// async loggedin(req, res, next) {
|
||||
// if(!req.session) {
|
||||
// return res.reply({
|
||||
// code: 401,
|
||||
// body: "401 - Unauthorized"
|
||||
// });
|
||||
// }
|
||||
// return next();
|
||||
// };
|
||||
|
||||
};
|
||||
|
@ -1,14 +1,17 @@
|
||||
import cfg from "../../inc/config.mjs";
|
||||
import lib from "../lib.mjs";
|
||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||
|
||||
export default (router, tpl) => {
|
||||
router.get(/^\/random$/, async (req, res) => {
|
||||
router.get(/^\/random$/, lib.loggedin, async (req, res) => {
|
||||
let referer = req.headers.referer ?? '';
|
||||
let opts = {};
|
||||
|
||||
if(referer.match(new RegExp(cfg.main.url.regex))) { // parse referer
|
||||
referer = referer.split(cfg.main.url.domain)[1];
|
||||
console.log("referer: ", referer);
|
||||
const tmp = referer.match(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/);
|
||||
console.log("tmp: ", tmp);
|
||||
if(tmp)
|
||||
opts = tmp.groups;
|
||||
}
|
||||
@ -22,6 +25,8 @@ export default (router, tpl) => {
|
||||
mode: req.session.mode,
|
||||
session: !!req.session
|
||||
});
|
||||
|
||||
console.log("data", data);
|
||||
|
||||
if(!data.success) {
|
||||
return res.reply({
|
||||
|
Reference in New Issue
Block a user