mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-09 07:25:21 +02:00
JSDoc fix
This commit is contained in:
parent
618123100e
commit
a6dfbe7024
3 changed files with 19 additions and 6 deletions
|
@ -1,23 +1,24 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
const router = express.Router();
|
||||||
const Users = require('../controllers/users');
|
const Users = require('../controllers/users');
|
||||||
const config = require('../../config/index');
|
const config = require('../../config/index');
|
||||||
|
|
||||||
const bcrypt = require('bcrypt');
|
const bcrypt = require('bcrypt');
|
||||||
// const saltRounds = 10;
|
|
||||||
|
|
||||||
const csrf = require('csurf');
|
const csrf = require('csurf');
|
||||||
const csrfProtection = csrf({ cookie: true });
|
const csrfProtection = csrf({ cookie: true });
|
||||||
const parseForm = bodyParser.urlencoded({ extended: false });
|
const parseForm = bodyParser.urlencoded({ extended: false });
|
||||||
|
|
||||||
/* GET authorization page. */
|
/**
|
||||||
|
* Authorization page
|
||||||
|
*/
|
||||||
router.get('/auth', csrfProtection, function (req, res) {
|
router.get('/auth', csrfProtection, function (req, res) {
|
||||||
res.render('auth', { title: 'Login page ', header: 'Enter password', csrfToken: req.csrfToken() });
|
res.render('auth', { title: 'Login page ', header: 'Enter password', csrfToken: req.csrfToken() });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process given password
|
||||||
|
*/
|
||||||
router.post('/auth', parseForm, csrfProtection, async (req, res) => {
|
router.post('/auth', parseForm, csrfProtection, async (req, res) => {
|
||||||
let salt = await Users.getSalt();
|
let salt = await Users.getSalt();
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
/**
|
||||||
|
* Middleware for checking locals.isAuthorized property, which allows to edit/create pages
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param next
|
||||||
|
*/
|
||||||
module.exports = function allowEdit(req, res, next) {
|
module.exports = function allowEdit(req, res, next) {
|
||||||
if (res.locals.isAuthorized) {
|
if (res.locals.isAuthorized) {
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -2,6 +2,12 @@ require('dotenv').config();
|
||||||
const config = require('../../../config/index');
|
const config = require('../../../config/index');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Middleware for checking jwt token
|
||||||
|
* @param req
|
||||||
|
* @param res
|
||||||
|
* @param next
|
||||||
|
*/
|
||||||
module.exports = async function verifyToken(req, res, next) {
|
module.exports = async function verifyToken(req, res, next) {
|
||||||
let token = req.cookies.authToken;
|
let token = req.cookies.authToken;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue