fix: update csrf parser to accept csrf_token form value if present

isekai-main
psibean 2 years ago committed by Julian Lam
parent cc147ab31d
commit ea95668a76

@ -9,8 +9,8 @@ const {
getTokenFromRequest: (req) => { getTokenFromRequest: (req) => {
if (req.headers['x-csrf-token']) { if (req.headers['x-csrf-token']) {
return req.headers['x-csrf-token']; return req.headers['x-csrf-token'];
} else if (req.query) { } else if (req.body.csrf_token) {
return req.query._csrf; return req.body.csrf_token;
} }
}, },
size: 64, size: 64,

@ -172,7 +172,7 @@ Auth.reloadRoutes = async function (params) {
router.post('/register', middlewares, controllers.authentication.register); router.post('/register', middlewares, controllers.authentication.register);
router.post('/register/complete', middlewares, controllers.authentication.registerComplete); router.post('/register/complete', middlewares, controllers.authentication.registerComplete);
router.post('/register/abort', Auth.middleware.applyCSRF, controllers.authentication.registerAbort); router.post('/register/abort', middlewares, controllers.authentication.registerAbort);
router.post('/login', Auth.middleware.applyCSRF, Auth.middleware.applyBlacklist, controllers.authentication.login); router.post('/login', Auth.middleware.applyCSRF, Auth.middleware.applyBlacklist, controllers.authentication.login);
router.post('/logout', Auth.middleware.applyCSRF, controllers.authentication.logout); router.post('/logout', Auth.middleware.applyCSRF, controllers.authentication.logout);
}; };

Loading…
Cancel
Save