hyperledger-fabrichyperledgerhyperledger-fabric-cahyperledger-chaincode

How to update the affiliation and attribute of member using fabric node


I have fabric network setup with 2 organisation and 2 fabric ca, I have register and enrolled the user.

 1. How i can update the affiliation of user, I am trying to call the getCaName from node js and reenroll its doest not work.

 2. How to change the attribute of user using fabric node .

 3. How to revoke the certificate.

Solution

  • @fama

    you can use my below snippet

    let adminUserObj = await client.setUserContext({
      username: admins.username,
      password: admins.secret
    });
    
    let caClient = client.getCertificateAuthority();
    
    let affiliationService = caClient.newAffiliationService();
    // Check if organization exists
    let registeredAffiliations = await affiliationService.getAll(adminUserObj);
    if (!registeredAffiliations.result.affiliations.some(x => x.name == userOrg.toLowerCase())) {
      let affiliation = userOrg.toLowerCase() + '.department1';
      await affiliationService.create({
        name: affiliation,
        force: true
      }, adminUserObj);
    }