-
Couldn't load subscription status.
- Fork 9
#73 Fix error while creating a review application #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = { | ||
| headers: { | ||
| authorization: token.startsWith('Bearer ') | ||
| ? token | ||
| : `Bearer ${token}`, | ||
| }, | ||
| }; | ||
|
|
||
| const mockRes = {}; | ||
| const res = {}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming the variable |
||
|
|
||
| const next = (error?: any) => { | ||
| if (error) { | ||
|
|
@@ -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')); | ||
|
|
@@ -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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from |
||
| }); | ||
|
|
||
| console.log(`Decoded token: ${JSON.stringify(payload)}`); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming
reqto something more descriptive, such asauthRequest, to clarify its purpose and distinguish it from other potential request objects.