Skip to content
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

- Change Password via OTP pin DTO fixes #84

Merged
merged 2 commits into from
Aug 21, 2023
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 .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;
}