20 lines
801 B
JavaScript
20 lines
801 B
JavaScript
const router = require('express-promise-router')()
|
|
const dictionary = require('../controllers/dictionaries')
|
|
|
|
// All routes require an authenticated user. Redirect to the site root, not
|
|
// req.baseUrl - unlike routes/dictionaries.js this router's own root ('/')
|
|
// is itself gated, so redirecting to req.baseUrl (== '/ogled-virov') would
|
|
// send an anonymous visitor straight back into the same check, looping.
|
|
router.use((req, res, next) => {
|
|
if (req.isAuthenticated()) return next()
|
|
res.redirect(303, '/')
|
|
})
|
|
|
|
// Show a read-only list of all dictionaries on the portal, regardless of status.
|
|
router.get('/', dictionary.listViewableDictionaries)
|
|
|
|
// Show read-only details for a specific dictionary.
|
|
router.get('/:dictionaryId/podatki', dictionary.viewDictionaryDetails)
|
|
|
|
module.exports = router
|