Remove external login tokens before removing external logins (#14341)

This commit is contained in:
Mole
2023-06-06 09:29:03 +02:00
committed by GitHub
parent 809883f088
commit b391fc50e9

View File

@@ -96,6 +96,9 @@ internal class ExternalLoginRepository : EntityRepositoryBase<int, IIdentityUser
// do the deletes, updates and inserts
if (toDelete.Count > 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<ExternalLoginTokenDto>().Where(x => toDelete.Contains(x.ExternalLoginId)).Execute();
Database.DeleteMany<ExternalLoginDto>().Where(x => toDelete.Contains(x.Id)).Execute();
}