Skip to content

Commit

Permalink
Merge pull request #20 from tekdi/v0.1.5
Browse files Browse the repository at this point in the history
Merge Aadhar card changes from 0.1.5 to main
  • Loading branch information
sudeeppr1998 authored Nov 29, 2024
2 parents a767b3b + bcc2d49 commit c11130c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/modules/user-docs/user-docs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CreateUserDocDto } from './dto/create-user-doc.dto';
import { ErrorResponse } from 'src/common/responses/error-response';
import { SuccessResponse } from 'src/common/responses/success-response';
import axios from 'axios'
import { v4 as uuidv4 } from 'uuid';
@Injectable()
export class UserDocsService {
constructor(
Expand Down Expand Up @@ -37,7 +38,20 @@ export class UserDocsService {
createUserDocDto.doc_data = vcJsonData;
createUserDocDto.issuer = vcJsonData.issuer;
}

if(createUserDocDto.doc_id == undefined ){
let uniqueUUID;
let isUnique = false;
while (!isUnique) {
uniqueUUID = 'did:ew:' + uuidv4();
const existDoc = await this.userDocsRepository.findOne({
where: { doc_id: uniqueUUID },
});
if (!existDoc) {
isUnique = true; // UUID is unique
}
}
createUserDocDto.doc_id = uniqueUUID;
}
const existingDoc = await this.userDocsRepository.findOne({
where: { doc_id: createUserDocDto.doc_id },
});
Expand Down

0 comments on commit c11130c

Please sign in to comment.