Refactor code structure for improved readability and maintainability

This commit is contained in:
Nawaz Dhandala
2026-02-12 20:46:28 +00:00
parent 2cb719d53a
commit 10d006890c
2 changed files with 8 additions and 1434 deletions

View File

@@ -177,10 +177,15 @@ export default class UserMiddleware {
try {
oneuptimeRequest.userAuthorization = JSONWebToken.decode(accessToken);
} catch (err) {
// if the token is invalid or expired, it'll throw this error.
// if the token is invalid or expired, return 401 so clients can refresh the token.
logger.error(err);
oneuptimeRequest.userType = UserType.Public;
return next();
return Response.sendErrorResponse(
req,
res,
new NotAuthenticatedException(
"AccessToken is invalid or expired. Please refresh your token.",
),
);
}
if (oneuptimeRequest.userAuthorization.isMasterAdmin) {

File diff suppressed because it is too large Load Diff