hidden comment overview behind login
This commit is contained in:
@@ -80,6 +80,18 @@ export default (router, tpl) => {
|
||||
const offset = (page - 1) * limit;
|
||||
const isJson = req.url.qs?.json === 'true';
|
||||
|
||||
// Require login
|
||||
if (!req.session || !req.session.user) {
|
||||
if (isJson) {
|
||||
return res.reply({
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ success: false, require_login: true })
|
||||
});
|
||||
} else {
|
||||
return res.redirect('/login');
|
||||
}
|
||||
}
|
||||
|
||||
const comments = await db`
|
||||
SELECT c.*, i.mime, i.id as item_id
|
||||
FROM comments c
|
||||
|
||||
Reference in New Issue
Block a user