Skip to content

Commit

Permalink
Merge pull request #127 from hypersign-protocol/issues#123
Browse files Browse the repository at this point in the history
fixed presetation count  issues
  • Loading branch information
varsha766 authored Nov 4, 2022
2 parents 0443c21 + 5468a9c commit 220619b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 3 additions & 11 deletions server/src/controllers/userProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@ const fetchUserDetail = async (req: Request, res: Response, next: NextFunction)
logger.info('profileCtrl:: fetchUserDetail() method start..');
const { data } = req.body.hypersign;
const orgsCount = await OrgModel.countDocuments({ userDid: data.id });
let schemasCount = await SchemaModel.countDocuments({ primaryDid: data.id });
// for backward compatibility
if (schemasCount === 0) {
schemasCount = await SchemaModel.countDocuments({ did: data.id });
}
let templatesCount = await PresentationModel.countDocuments({ primaryDid: data.id });
// for backward compatibility
if (templatesCount === 0) {
templatesCount = await PresentationModel.countDocuments({ templateOwnerDid: data.id });
}
const credentialsCount = await CredentialModel.countDocuments({ issuerDid: data.id });
const schemasCount = await SchemaModel.countDocuments({ primaryDid: data.id });
const templatesCount = await PresentationModel.countDocuments({ primaryDid: data.id });
const credentialsCount = await CredentialModel.countDocuments({ primaryDid: data.id });
logger.info('profileCtrl:: fetchUserDetail() method ends...');
return next(ApiResponse.success({ orgsCount, schemasCount, templatesCount, credentialsCount }));
} catch (e) {
Expand Down
8 changes: 6 additions & 2 deletions server/src/controllers/verifiableCredentialsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const setCredentialStatus = async (req: Request, res: Response, next: NextFuncti

const id = req.params.id;
if (!req.body.credStatus) {
const { issuerDid, subjectDid, schemaId } = req.body.vc;
const vc = req.body.vc;
const issuerDid = vc.issuer;
const subjectDid = vc.credentialSubject.id;
const schemaId = vc.credentialSchema.id;
const credObj = await creadSchema.findOneAndUpdate(
{ _id: id },
{
Expand Down Expand Up @@ -80,7 +83,7 @@ const issueCredential = async (req: Request, res: Response, next: NextFunction)
logger.info('==========CredController ::issueCredential Starts ================');
const { QR_DATA, hypersign } = req.body;
const { issuerDid, subjectDid, schemaId, orgDid, expirationDate } = QR_DATA.data;
QR_DATA.data.issuerDid = hypersign.data.id;
// QR_DATA.data.issuerDid = hypersign.data.id;

const creadObj = await creadSchema.create({
issuerDid,
Expand All @@ -90,6 +93,7 @@ const issueCredential = async (req: Request, res: Response, next: NextFunction)
createdAt: new Date(),
orgDid,
expiryDate: new Date(expirationDate),
primaryDid: hypersign.data.id,
});
QR_DATA.expirationDate = new Date(expirationDate);
QR_DATA.serviceEndpoint = `${WALLET_WEB_HOOK_CREAD}/${creadObj._id}`;
Expand Down
5 changes: 5 additions & 0 deletions server/src/models/CreadSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ICreadSchema extends Document {
vc_id: string;
orgDid: string;
expiryDate: Date;
primaryDid: string;
}

export const creadSchema = new Schema({
Expand Down Expand Up @@ -44,5 +45,9 @@ export const creadSchema = new Schema({
type: Date,
required: true,
},
primaryDid: {
type: String,
required: true,
},
});
export default mongoose.model<ICreadSchema>('CreadSchema', creadSchema);

0 comments on commit 220619b

Please sign in to comment.