fix_: filter private permissions & add Id keys in check_permissions_response (#5059)

This commit is contained in:
Ajay Sivan 2024-04-19 21:53:54 +05:30 committed by GitHub
parent 3baaac3e63
commit faf823f62f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -126,6 +126,7 @@ type PermissionTokenCriteriaResult struct {
Role protobuf.CommunityTokenPermission_Type `json:"roles"`
TokenRequirements []TokenRequirementResponse `json:"tokenRequirement"`
Criteria []bool `json:"criteria"`
ID string `json:"id"`
}
type AccountChainIDsCombination struct {

View File

@ -410,6 +410,12 @@ func (p *DefaultPermissionChecker) CheckPermissions(permissions []*CommunityToke
response.Permissions[tokenPermission.Id].TokenRequirements = append(response.Permissions[tokenPermission.Id].TokenRequirements, tokenRequirementResponse)
response.Permissions[tokenPermission.Id].Criteria = append(response.Permissions[tokenPermission.Id].Criteria, tokenRequirementMet)
}
response.Permissions[tokenPermission.Id].ID = tokenPermission.Id
if tokenPermission.IsPrivate && !permissionRequirementsMet {
delete(response.Permissions, tokenPermission.Id)
}
// multiple permissions are treated as logical OR, meaning
// if only one of them is fulfilled, the user gets permission
// to join and we can stop early