- Check that update route is authenticated

This commit is contained in:
2023-05-09 19:28:27 -04:00
parent c8b1b72694
commit 4499e20e77

View File

@@ -7,6 +7,7 @@ import Auth from '../../db/model/auth';
import { sign } from '../../utils/jwt';
import passport from '../passport';
import { ErrorCodes, getErrorBody } from '../../constants/errors';
import { authenticated } from '../middleware/authenication';
const routerOpts: Router.IRouterOptions = { prefix };
const router: Router = new Router(routerOpts);
@@ -43,7 +44,7 @@ router.post(process.env.RESET_ROUTE || RESET_ROUTE, async (ctx, next) => {
ctx.body = { success: false, ...getErrorBody(ErrorCodes.RESET_REQUEST_DATA) };
});
router.patch('/:record', (ctx: Koa.Context) => {
router.patch('/:record', authenticated(), (ctx: Koa.Context) => {
const data = Auth.findOneAndUpdate({ record: ctx.params.record });
if (!data) {
ctx.throw(StatusCodes.NOT_FOUND);