[bug] Do not request keys when we are not in the role in decryptAttribute
This commit is contained in:
parent
bb5d3ff16d
commit
6076c342f8
@ -1049,9 +1049,26 @@ export default class Services {
|
||||
return null;
|
||||
}
|
||||
let key = state.keys[attribute];
|
||||
const pairingProcessId = this.getPairingProcessId();
|
||||
|
||||
// If key is missing, request an update and then retry
|
||||
if (!key) {
|
||||
const roles = state.roles;
|
||||
let hasAccess = false;
|
||||
// If we're not supposed to have access to this attribute, ignore
|
||||
for (const role of Object.values(roles)) {
|
||||
if (role.validation_rules.includes(attribute)) {
|
||||
if (role.members.includes(pairingProcessId)) {
|
||||
// We have access to this attribute
|
||||
hasAccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAccess) return null;
|
||||
|
||||
// We should have the key, so we're going to ask other members for it
|
||||
await this.requestDataFromPeers(processId, [state.state_id], [state.roles]);
|
||||
|
||||
const maxRetries = 5;
|
||||
@ -1291,7 +1308,6 @@ export default class Services {
|
||||
await this.sendCommitMessage(JSON.stringify(content));
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
||||
public getRoles(process: Process): Record<string, RoleDefinition> | null {
|
||||
const lastCommitedState = this.getLastCommitedState(process);
|
||||
@ -1358,7 +1374,6 @@ export default class Services {
|
||||
|
||||
public async requestDataFromPeers(processId: string, stateIds: string[], roles: Record<string, RoleDefinition>[]) {
|
||||
console.log('Requesting data from peers');
|
||||
console.log(roles);
|
||||
const membersList = this.getAllMembers();
|
||||
try {
|
||||
const res = this.sdkClient.request_data(processId, stateIds, roles, membersList);
|
||||
|
Loading…
x
Reference in New Issue
Block a user