diff --git a/commonspace/object/acl/list/aclstate.go b/commonspace/object/acl/list/aclstate.go index 61fbfeab..8e332630 100644 --- a/commonspace/object/acl/list/aclstate.go +++ b/commonspace/object/acl/list/aclstate.go @@ -681,6 +681,13 @@ func (st *AclState) applyInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, rec }), } } + for _, rec := range st.requestRecords { + if rec.RequestIdentity.Equals(identity) { + delete(st.pendingRequests, mapKeyFromPubKey(rec.RequestIdentity)) + delete(st.requestRecords, rec.RecordId) + break + } + } if st.pubKey.Equals(identity) { return st.unpackAllKeys(ch.EncryptedReadKey) } diff --git a/commonspace/object/acl/list/acltestsuite.go b/commonspace/object/acl/list/acltestsuite.go index bf61312c..a3b178c8 100644 --- a/commonspace/object/acl/list/acltestsuite.go +++ b/commonspace/object/acl/list/acltestsuite.go @@ -218,7 +218,7 @@ func (a *AclTestExecutor) buildBatchRequest(args []string, acl AclList, getPerm } } if recId == "" { - return nil, fmt.Errorf("no join records for approve") + return nil, fmt.Errorf("no join records to approve") } perms := getPerm(argParts[1]) afterAll = append(afterAll, func() { @@ -461,7 +461,7 @@ func (a *AclTestExecutor) Execute(cmd string) (err error) { } } if recId == "" { - return fmt.Errorf("no join records for approve") + return fmt.Errorf("no join records to approve") } perms := getPerm(argParts[1]) res, err := acl.RecordBuilder().BuildRequestAccept(RequestAcceptPayload{ diff --git a/commonspace/object/acl/list/acltestsuite_test.go b/commonspace/object/acl/list/acltestsuite_test.go index ec06267f..5cefe156 100644 --- a/commonspace/object/acl/list/acltestsuite_test.go +++ b/commonspace/object/acl/list/acltestsuite_test.go @@ -90,7 +90,7 @@ func TestAclExecutor(t *testing.T) { {"g.join::inv1Id", nil}, {"g.cancel::g", nil}, // e cannot approve cancelled request - {"e.approve::g,rw", fmt.Errorf("no join records for approve")}, + {"e.approve::g,rw", fmt.Errorf("no join records to approve")}, {"g.join::inv1Id", nil}, {"e.decline::g", nil}, // g cannot cancel declined request @@ -144,6 +144,12 @@ func TestAclExecutor(t *testing.T) { {"new4.add::super,r,superm", nil}, // check that users can't join using request to join for anyone can join links {"new5.join::someId", ErrNoSuchInvite}, + {"a.invite::requestJoinId", nil}, + {"joiner.join::requestJoinId", nil}, + // check that users can join under a different link even after they created a request to join + {"joiner.invite_join::someId", nil}, + // check that they can't be approved after they joined under a different link + {"a.approve::joiner,rw", fmt.Errorf("no join records to approve")}, } for _, cmd := range cmds { err := a.Execute(cmd.cmd)