in case you are using composer-rest-server you can follow the comments on this link to implement local strategy.
However, in case you have your own rest server you can follow this steps:
1- Allow Participants to Register and add registration info to your database beside adding field pending = true,
so all Participants by default will be pending for admin approval.
2- Admin review user requests then run the following method.
Which creates new participant and issue identity bonded to this participant using adminCardName to sign those transactions of add and issue.
const IdentityIssue = require('composer-cli/lib/cmds/identity').Issue;
const ParticipantAdd = require('composer-cli/lib/cmds/participant').Add;
const CardImport = require('composer-cli/lib/cmds/card').Import;
const NetworkPing = require('composer-cli/lib/cmds/network').Ping;
const createParticipantCard = async (participantDetails) => {
const participantOptions = {
card: AdminCardName,
data: JSON.stringify({
$class: 'Name Space and type for your participant',
participantId: participantDetails.participantId,
email: participantDetails.email,
name: participantDetails.name,
}),
};
const issueOptions = {
card: AdminCardName,
file: `cards/identities/${participantDetails.participantId}.card`,
newUserId: participantDetails.participantId,
participantId:
`resource:org.finance.einvoice.participant.Company#
${participantDetails.participantId}`,
};
const importOptions = {
file: `cards/identities/${participantDetails.participantId}.card`,
card: participantDetails.participantId,
};
const pingOptions = {
card: participantDetails.participantId,
};
try {
await ParticipantAdd.handler(participantOptions);
await IdentityIssue.handler(issueOptions);
await CardImport.handler(importOptions);
await NetworkPing.handler(pingOptions);
return participantDetails.participantId;
} catch (err) {
throw err;
}
}
2- call this method at any file like following:
const createdParticipantId = await createParticipantCard(participantDetails);
than you can save createdParticipantId in your database and use it to query network to check if participant exists or it's identity has been revoked or submit transactions.