Skip to content

Commit 321b3fd

Browse files
authored
Merge pull request #15 from topcoder-platform/PM-921_qa-fixes
PM-921 qa fixes
2 parents cddc8d7 + 7102203 commit 321b3fd

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BHMKuGsgiBjJ7xHNxaJvBzrwdArogHSxEPmT6gNr5rZeXmJUWzrpQIstMXA9gEXX
88
LfKzG61idXFIwBa6t5YBCCMx+hoCxhcEiwIDAQAB
99
-----END RSA PUBLIC KEY-----"
1010
AUTH0_CLIENT_ID=BXWXUWnilVUPdN01t2Se29Tw2ZYNGZvH
11+
AUTH0_M2M_AUDIENCE=https://m2m.topcoder-dev.com/
1112

1213
DB_USERNAME=topcoderuser
1314
DB_PASSWORD=randompassword

src/api/admin-winning/adminWinning.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export class AdminWinningService {
100100
attributes: item.attributes,
101101
details: item.payment?.map((paymentItem) => ({
102102
id: paymentItem.payment_id,
103-
netAmount: paymentItem.net_amount,
104-
grossAmount: paymentItem.gross_amount,
103+
netAmount: Number(paymentItem.net_amount),
104+
grossAmount: Number(paymentItem.gross_amount),
105105
totalAmount: Number(paymentItem.total_amount),
106106
installmentNumber: paymentItem.installment_number,
107107
datePaid: paymentItem.date_paid ?? undefined,

src/api/winning/winning.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class WinningService {
5050

5151
const paymentData: Prisma.paymentCreateManyInput[] = body.details.map(
5252
(item) => ({
53-
net_amount: new Prisma.Decimal(item.grossAmount),
5453
total_amount: new Prisma.Decimal(item.totalAmount),
5554
gross_amount: new Prisma.Decimal(item.grossAmount),
5655
installment_number: item.installmentNumber,

src/core/auth/guards/auth.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export class AuthGuard implements CanActivate {
5050
[context.getHandler(), context.getClass()],
5151
);
5252

53-
const reqScopes = req.m2mTokenScope.split(' ')
54-
if (reqScopes.some(reqScope => allowedM2mScopes.includes(reqScope))) {
53+
const reqScopes = req.m2mTokenScope.split(' ');
54+
if (reqScopes.some((reqScope) => allowedM2mScopes.includes(reqScope))) {
5555
return true;
5656
}
5757
return false;

src/core/auth/middleware/tokenValidator.middleware.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,28 @@ export class TokenValidatorMiddleware implements NestMiddleware {
1616

1717
let decoded: any;
1818
try {
19-
decoded = jwt.verify(idToken, process.env.AUTH0_CERT, {
20-
audience: process.env.AUTH0_CLIENT_ID,
21-
});
19+
decoded = jwt.verify(idToken, process.env.AUTH0_CERT);
2220
} catch (error) {
2321
console.error('Error verifying JWT', error);
2422
throw new UnauthorizedException('Invalid or expired JWT!');
2523
}
2624

27-
// TODO: verify decoded.aud
2825
if (!decoded) {
2926
req.idTokenVerified = false;
3027
return next();
3128
}
3229

33-
req.idTokenVerified = true;
3430
req.isM2M = !!decoded.scope;
31+
const aud = req.isM2M
32+
? process.env.AUTH0_M2M_AUDIENCE
33+
: process.env.AUTH0_CLIENT_ID;
34+
35+
if (decoded.aud !== aud) {
36+
req.idTokenVerified = false;
37+
return next();
38+
}
3539

40+
req.idTokenVerified = true;
3641
if (decoded.scope) {
3742
req.m2mTokenScope = decoded.scope;
3843
req.m2mTokenAudience = decoded.aud;

src/dto/adminWinning.dto.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,6 @@ export class WinningUpdateRequestDto {
348348
}
349349

350350
export class PaymentCreateRequestDto {
351-
@ApiProperty({
352-
description: 'The net amount of the payment',
353-
example: 12.3,
354-
})
355-
@IsNumber()
356-
@Min(0)
357-
netAmount: number;
358-
359351
@ApiProperty({
360352
description: 'The total amount of the payment',
361353
example: 12.3,

0 commit comments

Comments
 (0)