fix: remove unnecessary function & move session setup step to exist...

ing middleware
pull/239/head
Josh Moore 1 year ago
parent 5d06745ceb
commit 04ef991fbc

@ -30,6 +30,11 @@ const assMetaMiddleware = (port: number, proxied: boolean): RequestHandler =>
host: `${req.protocol}://${req.hostname}${proxied ? '' : `:${port}`}`,
version: App.pkgVersion
};
// Set up Session if required
if (!req.session.ass)
(log.debug('Session missing'), req.session.ass = {});
next();
};

@ -9,18 +9,6 @@ import { nanoid } from '../generators';
import { UserConfig } from '../UserConfig';
import { MySql } from '../sql/mysql';
/**
* Validates a user login session
*/
const validateSessions: RequestHandler = (req, res, next) => {
if (!req.session.ass) (log.debug('Session missing'), req.session.ass = {});
// todo: actually authenticate (data.get needs to be updated for subproperties maybe)
// data.get('')
next();
};
const router = Router({ caseSensitive: true });
// Setup route
@ -50,7 +38,7 @@ router.post('/setup', BodyParserJson(), async (req, res) => {
});
// User login
router.post('/login', BodyParserJson(), validateSessions, (req, res) => {
router.post('/login', BodyParserJson(), (req, res) => {
const { username, password } = req.body;
data.getAll('users')

Loading…
Cancel
Save