This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/server/routes/admin.js
2017-08-27 21:39:30 +03:00

50 lines
1018 B
JavaScript

import express from 'express'
import multiparty from 'multiparty'
import config from '../../scripts/load-config'
import wrap from '../../scripts/asyncRoute'
import API from '../api'
import News from '../api/news'
import Image from '../api/image'
import APIExtern from '../api/external'
const router = express.Router()
const apiRouter = express.Router()
router.use(wrap(async (req, res, next) => {
if (!req.session.user) return res.redirect('/login')
if (!req.session.privilege) {
let u = await API.User.get(req.session.user)
req.session.privilege = u.nw_privilege
}
if (req.session.user && req.session.privilege !== 5) {
return res.redirect('/login')
}
res.locals.server_time = process.uptime()
next()
}))
/* =========
* VIEWS
* =========
*/
router.get('/', (req, res) => {
res.render('admin/index')
})
router.get('/oauth2', wrap(async (req, res) => {
res.render('admin/oauth2')
}))
/* =======
* API
* =======
*/
router.use('/api', apiRouter)
module.exports = router