Skip to content

Commit 3441e63

Browse files
Merge pull request #111 from Amruth-Vamshi/feature/WA-provider
2 parents d3348a0 + 4127fde commit 3441e63

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/api/api.service.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ export class ApiService {
749749
const salt = this.configResolverService.getSalt(loginDto.applicationId);
750750
const password = salt + this.configService.get('DEFAULT_USER_PASSWORD'); // mix OTP with salt
751751
console.log(password);
752+
let response;
752753

753754
const { statusFA }: { statusFA: FAStatus } =
754755
await this.fusionAuthService.getUser(
@@ -757,7 +758,7 @@ export class ApiService {
757758
authHeader,
758759
);
759760
if (statusFA === FAStatus.USER_EXISTS) {
760-
return this.login({ ...loginDto, password }, authHeader);
761+
response = await this.login({ ...loginDto, password }, authHeader);
761762
} else {
762763
// create a new user
763764
const createUserPayload: UserRegistration = {
@@ -781,8 +782,22 @@ export class ApiService {
781782
if (userId == null || user == null) {
782783
throw new HttpException(err, HttpStatus.BAD_REQUEST);
783784
}
784-
return this.login({ ...loginDto, password }, authHeader);
785+
response = await this.login({ ...loginDto, password }, authHeader);
785786
}
787+
let existingJWTS: any = await this.redis.get(
788+
response?.result?.data?.user?.user?.id,
789+
);
790+
if (existingJWTS) {
791+
existingJWTS = JSON.parse(existingJWTS);
792+
} else {
793+
existingJWTS = [];
794+
}
795+
existingJWTS.push(response?.result?.data?.user?.token);
796+
await this.redis.set(
797+
response?.result?.data?.user?.user?.id,
798+
JSON.stringify(existingJWTS),
799+
);
800+
return response;
786801
}
787802

788803
async updateUserRegistration(

0 commit comments

Comments
 (0)