mirror of
https://github.com/sasjs/server.git
synced 2026-04-10 15:43:14 +00:00
chore: added desktop mode + drive tmp folder fix
This commit is contained in:
@@ -28,6 +28,9 @@ const authenticateToken = (
|
||||
key: string,
|
||||
tokenType: 'accessToken' | 'refreshToken' = 'accessToken'
|
||||
) => {
|
||||
const { MODE } = process.env
|
||||
if (MODE === 'desktop') return next()
|
||||
|
||||
const authHeader = req.headers['authorization']
|
||||
const token = authHeader?.split(' ')[1]
|
||||
if (!token) return res.sendStatus(401)
|
||||
|
||||
7
api/src/middlewares/desktopRestrict.ts
Normal file
7
api/src/middlewares/desktopRestrict.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const desktopRestrict = (req: any, res: any, next: any) => {
|
||||
const { MODE } = process.env
|
||||
if (MODE === 'desktop')
|
||||
return res.status(403).send('Not Allowed while in Desktop Mode.')
|
||||
|
||||
next()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './authenticateToken'
|
||||
export * from './desktopRestrict'
|
||||
export * from './verifyAdmin'
|
||||
export * from './verifyAdminIfNeeded'
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export const verifyAdmin = (req: any, res: any, next: any) => {
|
||||
const { MODE } = process.env
|
||||
if (MODE === 'desktop') return next()
|
||||
|
||||
const { user } = req
|
||||
if (!user?.isAdmin) return res.status(401).send('Admin account required')
|
||||
next()
|
||||
|
||||
Reference in New Issue
Block a user