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