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 nikolajlauridsen
parent 407263d090
commit b5ab115318

View File

@@ -109,6 +109,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();
}