fix: Improved handling of authentication edge-cases (#2023)

* fix: authentication records not cleaned up for deleted user
closes #2022

* fix: Improve debugging for duplicate providerId sign-in requests
This commit is contained in:
Tom Moor
2021-04-11 19:39:31 -07:00
committed by GitHub
parent bc4fe05147
commit 62f9262b2c
4 changed files with 92 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import { sendEmail } from "../mailer";
import { DataTypes, sequelize, encryptedFields, Op } from "../sequelize";
import { DEFAULT_AVATAR_HOST } from "../utils/avatars";
import { publicS3Endpoint, uploadToS3FromUrl } from "../utils/s3";
import UserAuthentication from "./UserAuthentication";
import { Star, Team, Collection, NotificationSetting, ApiKey } from ".";
const User = sequelize.define(
@ -208,6 +209,10 @@ const removeIdentifyingInfo = async (model, options) => {
where: { userId: model.id },
transaction: options.transaction,
});
await UserAuthentication.destroy({
where: { userId: model.id },
transaction: options.transaction,
});
model.email = null;
model.name = "Unknown";