mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Simplified error pages for /a/ route
Send 404 error page when identifier is missing or album is not public.
This commit is contained in:
parent
5f8bad907c
commit
255a5992b5
@ -8,10 +8,7 @@ const db = require('knex')(config.database)
|
|||||||
routes.get('/a/:identifier', async (req, res, next) => {
|
routes.get('/a/:identifier', async (req, res, next) => {
|
||||||
const identifier = req.params.identifier
|
const identifier = req.params.identifier
|
||||||
if (identifier === undefined)
|
if (identifier === undefined)
|
||||||
return res.status(401).json({
|
res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
||||||
success: false,
|
|
||||||
description: 'No identifier provided.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const album = await db.table('albums')
|
const album = await db.table('albums')
|
||||||
.where({
|
.where({
|
||||||
@ -21,13 +18,8 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
|||||||
.select('id', 'name', 'identifier', 'editedAt', 'download', 'public', 'description')
|
.select('id', 'name', 'identifier', 'editedAt', 'download', 'public', 'description')
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
if (!album)
|
if (!album || album.public === 0)
|
||||||
return res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
return res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
||||||
else if (album.public === 0)
|
|
||||||
return res.status(403).json({
|
|
||||||
success: false,
|
|
||||||
description: 'This album is not available for public.'
|
|
||||||
})
|
|
||||||
|
|
||||||
const nojs = req.query.nojs !== undefined
|
const nojs = req.query.nojs !== undefined
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user