Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsaporiti committed Apr 5, 2024
1 parent b72dbbd commit 1b155c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/core/services/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func (i *identity) GetKeyIDFromAuthClaim(ctx context.Context, authClaim *domain.
}

func (i *identity) UpdateState(ctx context.Context, did w3c.DID) (*domain.IdentityState, error) {
const authBJJCredential = "https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential"
newState := &domain.IdentityState{
Identifier: did.String(),
Status: domain.StatusCreated,
Expand Down Expand Up @@ -339,7 +338,7 @@ func (i *identity) UpdateState(ctx context.Context, did w3c.DID) (*domain.Identi
}

// Check if there are claims to process
if err := checkClaimsToAdd(lc, authBJJCredential); err != nil {
if err := checkClaimsToAdd(lc); err != nil {
return err
}

Expand Down Expand Up @@ -406,8 +405,12 @@ func (i *identity) UpdateState(ctx context.Context, did w3c.DID) (*domain.Identi

// checkClaimsToAdd checks if there are claims to process
// if the len of the claims is 0 or the len is 1 and the claim is the authBJJCredential then return an error
func checkClaimsToAdd(lc []domain.Claim, authCoreClaim string) error {
if len(lc) == 0 || (len(lc) == 1 && lc[0].SchemaType == authCoreClaim) {
func checkClaimsToAdd(lc []domain.Claim) error {
if len(lc) == 0 {
return ErrNoClaimsFoundToProcess
}

if len(lc) == 1 && lc[0].SchemaType == domain.AuthBJJCredentialTypeID {
return ErrNoClaimsFoundToProcess
}
return nil
Expand Down

0 comments on commit 1b155c1

Please sign in to comment.