mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Update request to join logic to include cases with two invite links
This commit is contained in:
parent
3b9880eff8
commit
20f79ee139
3 changed files with 16 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue