mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-07 22:45:23 +02:00
Added verifyToken middleware to aliases route, added check for user existance on POST/auth
This commit is contained in:
parent
90c7a2e363
commit
ae18f115f0
2 changed files with 6 additions and 1 deletions
|
@ -3,13 +3,14 @@ const router = express.Router();
|
|||
const Aliases = require('../controllers/aliases');
|
||||
const Pages = require('../controllers/pages');
|
||||
const Alias = require('../models/alias');
|
||||
const verifyToken = require('./middlewares/token');
|
||||
|
||||
/**
|
||||
* GET /*
|
||||
*
|
||||
* Return document with given alias
|
||||
*/
|
||||
router.get('*', async (req, res) => {
|
||||
router.get('*', verifyToken, async (req, res) => {
|
||||
try {
|
||||
const alias = await Aliases.get(req.originalUrl.slice(1)); // Cuts first '/' character
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ router.get('/auth', csrfProtection, function (req, res) {
|
|||
router.post('/auth', parseForm, csrfProtection, async (req, res) => {
|
||||
let userDoc = await Users.get();
|
||||
|
||||
if (!userDoc) {
|
||||
throw new Error('Password not set');
|
||||
}
|
||||
|
||||
const passHash = userDoc.passHash;
|
||||
|
||||
bcrypt.compare(req.body.password, passHash, async (err, result) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue