🐛 Remove all 3pids and not just the first one.

This commit is contained in:
danielaloni 2022-10-31 13:17:36 +02:00
parent 193d4ecaa9
commit d1f3bf502e
2 changed files with 10 additions and 4 deletions

View file

@ -553,10 +553,11 @@ func (a *UserInternalAPI) PerformAccountDeactivation(ctx context.Context, req *a
if err != nil {
return err
}
err = a.DB.RemoveThreePIDAssociation(ctx, threepids[0].Address, threepids[0].Medium)
if err != nil {
return err
for i := 0; i < len(threepids); i++ {
err = a.DB.RemoveThreePIDAssociation(ctx, threepids[i].Address, threepids[i].Medium)
if err != nil {
return err
}
}
pusherReq := &api.PerformPusherDeletionRequest{

View file

@ -128,6 +128,11 @@ func Test_Accounts(t *testing.T) {
_, err = db.GetAccountByPassword(ctx, aliceLocalpart, "newPassword")
assert.Error(t, err, "expected an error, got none")
// This should return an empty slice, as the account is deactivated and the 3pid is unbound
threepids, err := db.GetThreePIDsForLocalpart(ctx, aliceLocalpart)
assert.NoError(t, err, "failed to get 3pid for account")
assert.Equal(t, len(threepids), 0)
_, err = db.GetAccountByLocalpart(ctx, "unusename")
assert.Error(t, err, "expected an error for non existent localpart")