Skip to content

Commit

Permalink
Merge pull request #84 from Samagra-Development/hotfix/validation-fixes
Browse files Browse the repository at this point in the history
- Change Password via OTP pin DTO fixes
  • Loading branch information
charanpreet-s authored Aug 21, 2023
2 parents a2c1861 + 6546f29 commit 2d8528e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14]
node-version: [16]

steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 7 additions & 4 deletions src/api/api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { FusionauthService } from './fusionauth/fusionauth.service';
import { OtpService } from './otp/otp.service';
import { SMSResponse } from './sms/sms.interface';
import { RefreshRequest } from '@fusionauth/typescript-client/build/src/FusionAuthClient';
import { ChangePasswordDTO } from '../user/dto/changePassword.dto';
import { ChangePasswordDTO } from './dto/changePassword.dto';
import { SentryInterceptor } from '../interceptors/sentry.interceptor';
import * as Sentry from '@sentry/node';
import { LoginDto } from './dto/login.dto';
Expand Down Expand Up @@ -99,8 +99,12 @@ export class ApiController {
encodedBase64Key === undefined
? CryptoJS.enc.Base64.parse('bla')
: CryptoJS.enc.Base64.parse(encodedBase64Key);
user.loginId = this.apiService.decrypt(user.loginId, parsedBase64Key);
user.password = this.apiService.decrypt(user.password, parsedBase64Key);
const loginId = this.apiService.decrypt(user.loginId, parsedBase64Key);
const password = this.apiService.decrypt(user.password, parsedBase64Key);

// if we are not able to decrypt, we'll try to authenticate with the original creds
user.loginId = loginId ? loginId : user.loginId;
user.password = password ? password : user.password;
}
return await this.apiService.login(user, authHeader);
}
Expand Down Expand Up @@ -230,7 +234,6 @@ export class ApiController {
@Headers('authorization') authHeader,
@Headers('x-application-id') applicationId,
): Promise<UsersResponse> {
console.log(query.numberOfResults);
return await this.apiService.fetchUsersByString(
query.queryString,
query.startRow,
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const otpServiceFactory = {
ConfigResolverService,
{
provide: APP_PIPE,
useValue: new ValidationPipe(),
useValue: new ValidationPipe({ transform: true }),
},
],
})
Expand Down
15 changes: 15 additions & 0 deletions src/api/dto/changePassword.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IsNotEmpty, IsString } from 'class-validator';

export class ChangePasswordDTO {
@IsString()
@IsNotEmpty()
username: string;

@IsString()
@IsNotEmpty()
password: string;

@IsString()
@IsNotEmpty()
OTP: string;
}

0 comments on commit 2d8528e

Please sign in to comment.