From b391fc50e9a3a4a6a417df01ac451e46458a69bd Mon Sep 17 00:00:00 2001 From: Mole Date: Tue, 6 Jun 2023 09:29:03 +0200 Subject: [PATCH] Remove external login tokens before removing external logins (#14341) --- .../Repositories/Implement/ExternalLoginRepository.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs index e49e2ffda9..352b1dd3fd 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs @@ -96,6 +96,9 @@ internal class ExternalLoginRepository : EntityRepositoryBase 0) { + // Before we can remove the external login, we must remove the external login tokens associated with that external login, + // otherwise we'll get foreign key constraint errors + Database.DeleteMany().Where(x => toDelete.Contains(x.ExternalLoginId)).Execute(); Database.DeleteMany().Where(x => toDelete.Contains(x.Id)).Execute(); }