From 414fb19de3fe4f0cfe98076868476604a390c0c8 Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 30 May 2022 00:32:05 +0500 Subject: [PATCH] chore: code changes --- api/package.json | 2 +- api/src/routes/api/stp.ts | 9 +++++---- api/src/routes/web/web.ts | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/api/package.json b/api/package.json index cf8b3a6..bd6f562 100644 --- a/api/package.json +++ b/api/package.json @@ -96,7 +96,7 @@ }, "nodemonConfig": { "ignore": [ - "tmp/**/*" + "sasjs_root/**/*" ] } } diff --git a/api/src/routes/api/stp.ts b/api/src/routes/api/stp.ts index c759a9d..5ea37db 100644 --- a/api/src/routes/api/stp.ts +++ b/api/src/routes/api/stp.ts @@ -47,10 +47,11 @@ stpRouter.post( query?._program ) - if (response instanceof Buffer) { - res.writeHead(200, (req as any).sasHeaders) - return res.end(response) - } + // TODO: investigate if this code is required + // if (response instanceof Buffer) { + // res.writeHead(200, (req as any).sasHeaders) + // return res.end(response) + // } res.send(response) } catch (err: any) { diff --git a/api/src/routes/web/web.ts b/api/src/routes/web/web.ts index c64478f..c4d817c 100644 --- a/api/src/routes/web/web.ts +++ b/api/src/routes/web/web.ts @@ -1,6 +1,6 @@ import express from 'express' import { WebController } from '../../controllers/web' -import { authenticateAccessToken } from '../../middlewares' +import { authenticateAccessToken, desktopRestrict } from '../../middlewares' import { authorizeValidation, loginWebValidation } from '../../utils' const webRouter = express.Router() @@ -19,7 +19,7 @@ webRouter.get('/', async (req, res) => { } }) -webRouter.post('/SASLogon/login', async (req, res) => { +webRouter.post('/SASLogon/login', desktopRestrict, async (req, res) => { const { error, value: body } = loginWebValidation(req.body) if (error) return res.status(400).send(error.details[0].message) @@ -33,6 +33,7 @@ webRouter.post('/SASLogon/login', async (req, res) => { webRouter.post( '/SASLogon/authorize', + desktopRestrict, authenticateAccessToken, async (req, res) => { const { error, value: body } = authorizeValidation(req.body) @@ -47,7 +48,7 @@ webRouter.post( } ) -webRouter.get('/logout', async (req, res) => { +webRouter.get('/logout', desktopRestrict, async (req, res) => { try { await controller.logout(req) res.status(200).send('OK!')