Wiping more information
Ensuring documents and collections created by user still load
This commit is contained in:
@ -141,8 +141,8 @@ Document.associate = models => {
|
|||||||
{
|
{
|
||||||
include: [
|
include: [
|
||||||
{ model: models.Collection, as: 'collection' },
|
{ model: models.Collection, as: 'collection' },
|
||||||
{ model: models.User, as: 'createdBy' },
|
{ model: models.User, as: 'createdBy', paranoid: false },
|
||||||
{ model: models.User, as: 'updatedBy' },
|
{ model: models.User, as: 'updatedBy', paranoid: false },
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
publishedAt: {
|
publishedAt: {
|
||||||
@ -156,8 +156,8 @@ Document.associate = models => {
|
|||||||
Document.addScope('withUnpublished', {
|
Document.addScope('withUnpublished', {
|
||||||
include: [
|
include: [
|
||||||
{ model: models.Collection, as: 'collection' },
|
{ model: models.Collection, as: 'collection' },
|
||||||
{ model: models.User, as: 'createdBy' },
|
{ model: models.User, as: 'createdBy', paranoid: false },
|
||||||
{ model: models.User, as: 'updatedBy' },
|
{ model: models.User, as: 'updatedBy', paranoid: false },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
Document.addScope('withViews', userId => ({
|
Document.addScope('withViews', userId => ({
|
||||||
|
@ -25,7 +25,7 @@ const User = sequelize.define(
|
|||||||
slackData: DataTypes.JSONB,
|
slackData: DataTypes.JSONB,
|
||||||
jwtSecret: encryptedFields.vault('jwtSecret'),
|
jwtSecret: encryptedFields.vault('jwtSecret'),
|
||||||
lastActiveAt: DataTypes.DATE,
|
lastActiveAt: DataTypes.DATE,
|
||||||
lastActiveIp: DataTypes.STRING,
|
lastActiveIp: { type: DataTypes.STRING, allowNull: true },
|
||||||
lastSignedInAt: DataTypes.DATE,
|
lastSignedInAt: DataTypes.DATE,
|
||||||
lastSignedInIp: DataTypes.STRING,
|
lastSignedInIp: DataTypes.STRING,
|
||||||
suspendedAt: DataTypes.DATE,
|
suspendedAt: DataTypes.DATE,
|
||||||
@ -92,12 +92,18 @@ const setRandomJwtSecret = model => {
|
|||||||
model.jwtSecret = crypto.randomBytes(64).toString('hex');
|
model.jwtSecret = crypto.randomBytes(64).toString('hex');
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeIdentifyingInfo = model => {
|
const removeIdentifyingInfo = async model => {
|
||||||
model.email = '';
|
model.email = '';
|
||||||
model.username = '';
|
model.name = 'Unknown';
|
||||||
|
model.avatarUrl = '';
|
||||||
|
model.serviceId = '';
|
||||||
|
model.username = null;
|
||||||
model.slackData = null;
|
model.slackData = null;
|
||||||
model.serviceId = null;
|
model.lastActiveIp = null;
|
||||||
model.isAdmin = false;
|
|
||||||
|
// this shouldn't be needed once this issue is resolved:
|
||||||
|
// https://github.com/sequelize/sequelize/issues/9318
|
||||||
|
await model.save({ hooks: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkLastAdmin = async model => {
|
const checkLastAdmin = async model => {
|
||||||
|
Reference in New Issue
Block a user