1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-11 08:20:04 +00:00

feat: bypass authentication when route is enabled for public group

This commit is contained in:
2022-08-02 18:06:33 +05:00
parent d3a516c36e
commit 68515f95a6
3 changed files with 40 additions and 1 deletions

View File

@@ -5,7 +5,9 @@ import {
fetchLatestAutoExec,
ModeType,
verifyTokenInDB,
isAuthorizingRoute
isAuthorizingRoute,
isPublicRoute,
publicUser
} from '../utils'
import { desktopUser } from './desktop'
import { authorize } from './authorize'
@@ -21,6 +23,11 @@ export const authenticateAccessToken: RequestHandler = async (
return next()
}
if (await isPublicRoute(req)) {
req.user = publicUser
return next()
}
const nextFunction = isAuthorizingRoute(req)
? () => authorize(req, res, next)
: next