CreateAccount: Rollback creation of all ext IDs if insert of email fails

On account creation there are 2 transactions that insert external IDs:
1. external ID for username + external IDs from external ID creators
2. external ID for email

If the second transaction fails because the email is already used by
another account only the creation of the username external ID was rolled
back, but not the creation of the external IDs from the external ID
creators. This is inconsistent and we should rather rollback all created
external IDs.

Change-Id: If146b853bfdb41af564cab2643d6d31cdce09015
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-12-19 12:41:05 +01:00
parent fb976d7c44
commit 0a1c1da3ce

View File

@@ -162,7 +162,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
externalIdsUpdate.insert(ExternalId.createEmail(id, input.email));
} catch (OrmDuplicateKeyException duplicateKey) {
try {
externalIdsUpdate.delete(extUser);
externalIdsUpdate.delete(extIds);
} catch (IOException | ConfigInvalidException cleanupError) {
// Ignored
}