Skip to content

Commit

Permalink
Merge pull request #111 from Amruth-Vamshi/feature/WA-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ChakshuGautam authored Jan 2, 2025
2 parents d3348a0 + 4127fde commit 3441e63
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ export class ApiService {
const salt = this.configResolverService.getSalt(loginDto.applicationId);
const password = salt + this.configService.get('DEFAULT_USER_PASSWORD'); // mix OTP with salt
console.log(password);
let response;

const { statusFA }: { statusFA: FAStatus } =
await this.fusionAuthService.getUser(
Expand All @@ -757,7 +758,7 @@ export class ApiService {
authHeader,
);
if (statusFA === FAStatus.USER_EXISTS) {
return this.login({ ...loginDto, password }, authHeader);
response = await this.login({ ...loginDto, password }, authHeader);
} else {
// create a new user
const createUserPayload: UserRegistration = {
Expand All @@ -781,8 +782,22 @@ export class ApiService {
if (userId == null || user == null) {
throw new HttpException(err, HttpStatus.BAD_REQUEST);
}
return this.login({ ...loginDto, password }, authHeader);
response = await this.login({ ...loginDto, password }, authHeader);
}
let existingJWTS: any = await this.redis.get(
response?.result?.data?.user?.user?.id,
);
if (existingJWTS) {
existingJWTS = JSON.parse(existingJWTS);
} else {
existingJWTS = [];
}
existingJWTS.push(response?.result?.data?.user?.token);
await this.redis.set(
response?.result?.data?.user?.user?.id,
JSON.stringify(existingJWTS),
);
return response;
}

async updateUserRegistration(
Expand Down

0 comments on commit 3441e63

Please sign in to comment.