Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/review-application/reviewApplication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ReviewApplicationService {
authUser: JwtUser,
dto: CreateReviewApplicationDto,
): Promise<ReviewApplicationResponseDto> {
const userId = authUser.userId as string;
const userId = String(authUser.userId);
const handle = authUser.handle as string;

try {
Expand Down
10 changes: 5 additions & 5 deletions src/shared/modules/global/jwt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ export class JwtService implements OnModuleInit {
try {
// Use tc-core-library-js for JWT validation
const payload = await new Promise<any>((resolve, reject) => {
// Create a mock request object with the authorization header
const mockReq = {
// Create a request object with the authorization header
const req = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming req to something more descriptive, such as authRequest, to clarify its purpose and distinguish it from other potential request objects.

headers: {
authorization: token.startsWith('Bearer ')
? token
: `Bearer ${token}`,
},
};

const mockRes = {};
const res = {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the variable res to something more descriptive to clarify its purpose and usage within the code.


const next = (error?: any) => {
if (error) {
Expand All @@ -64,7 +64,7 @@ export class JwtService implements OnModuleInit {
}

// tc-core-library-js should have attached authUser to the request
const authUser = (mockReq as any).authUser;
const authUser = (req as any).authUser;

if (!authUser) {
return reject(new UnauthorizedException('Invalid token'));
Expand All @@ -74,7 +74,7 @@ export class JwtService implements OnModuleInit {
};

// Call the tc-core-library-js authenticator
this.jwtAuthenticator(mockReq, mockRes, next);
this.jwtAuthenticator(req, res, next);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from mockReq and mockRes to req and res suggests that the actual request and response objects are now being used. Ensure that req and res are correctly initialized and contain the expected properties before passing them to jwtAuthenticator. This change might affect how the authenticator processes the request and response, so verify that it behaves as intended with real objects.

});

console.log(`Decoded token: ${JSON.stringify(payload)}`);
Expand Down