Commit 80d1f499 authored by Girish Ramakrishnan's avatar Girish Ramakrishnan

return 400 for invalid request

parent 4c8e739c
......@@ -279,7 +279,7 @@ const onClientConnect = (req, res, next) => {
const token = req.body['token']
if (token !== ADMIN_TOKEN) return next(new HttpError(401, 'Unauthorized'))
if (!cn || !remoteIp || !vpnIp) return next(new HttpError(409, 'Invalid Request'))
if (!cn || !remoteIp || !vpnIp) return next(new HttpError(400, 'Invalid Request'))
const match = /^.*\/([A-Za-z0-9.]+)\/([A-Za-z0-9\-_]+)$/.exec(cn) // cn is the full path of the key that matched
if (!match) return next(new HttpError(409, 'Invalid Request'))
......@@ -304,7 +304,7 @@ const onClientDisconnect = (req, res, next) => {
const token = req.body['token']
if (token !== ADMIN_TOKEN) return next(new HttpError(401, 'Unauthorized'))
if (!cn) return next(new HttpError(409, 'Invalid Request'))
if (!cn) return next(new HttpError(400, 'Invalid Request'))
const match = /^.*\/([A-Za-z0-9.]+)\/([A-Za-z0-9\-_]+)$/.exec(cn) // cn is the full path of the key that matched
if (!match) return next(new HttpError(409, 'Invalid Request'))
......@@ -324,9 +324,9 @@ const onLearnAddress = (req, res, next) => {
const token = req.body['token']
if (token !== ADMIN_TOKEN) return next(new HttpError(401, 'Unauthorized'))
if (!operation || !vpnIp) return next(new HttpError(409, 'Invalid Request'))
if (!operation.match(/^(add|update|delete)$/)) return next(new HttpError(409, 'Invalid operation'))
if (operation.match(/^(add|update)$/) && !cn) return next(new HttpError(409, 'cn is required'))
if (!operation || !vpnIp) return next(new HttpError(400, 'Invalid Request'))
if (!operation.match(/^(add|update|delete)$/)) return next(new HttpError(400, 'Invalid operation'))
if (operation.match(/^(add|update)$/) && !cn) return next(new HttpError(400, 'cn is required'))
if (operation === 'add' || operation === 'update') {
const match = /^.*\/([A-Za-z0-9.]+)\/([A-Za-z0-9\-_]+)$/.exec(cn) // cn is the full path of the key that matched
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment