🚧 backend: wip initial setup for admin route to delete user (#799)
This commit is contained in:
committed by
Anton Shepilov
parent
185ec5ac5c
commit
16c68f25fd
@@ -78,6 +78,12 @@ export default class User {
|
||||
@Column("deleted", "tdrive_boolean")
|
||||
deleted: boolean;
|
||||
|
||||
/**
|
||||
* If set, a restartable suppression process is currently incomplete.
|
||||
*/
|
||||
@Column("delete_process_started_epoch", "number")
|
||||
delete_process_started_epoch?: number;
|
||||
|
||||
@Column("mail_verified", "tdrive_boolean")
|
||||
mail_verified: boolean;
|
||||
|
||||
|
||||
@@ -310,7 +310,11 @@ export class CompanyServiceImpl {
|
||||
for (const company of companies) {
|
||||
logger.warn(`User ${userPk.id} is deleted so removed from company ${company.id}`);
|
||||
await this.removeUserFromCompany(company, user);
|
||||
await gr.services.workspaces.ensureUserNotInCompanyIsNotInWorkspace(userPk, company.id);
|
||||
try {
|
||||
await gr.services.workspaces.ensureUserNotInCompanyIsNotInWorkspace(userPk, company.id);
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Error removing user from company from workspace");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ export class UserServiceImpl {
|
||||
user.thumbnail_id = null;
|
||||
user.status_icon = null;
|
||||
user.deleted = true;
|
||||
user.delete_process_started_epoch = new Date().getTime();
|
||||
|
||||
await this.save(user);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export const userObjectSchema = {
|
||||
last_name: { type: "string" },
|
||||
created_at: { type: "number" },
|
||||
deleted: { type: "boolean" },
|
||||
delete_process_started_epoch: { type: "number" },
|
||||
|
||||
status: { type: "string" },
|
||||
last_activity: { type: "number" },
|
||||
|
||||
@@ -732,9 +732,11 @@ export class WorkspaceServiceImpl implements TdriveServiceProvider, Initializabl
|
||||
logger.warn(
|
||||
`User ${userPk.id} is not in company ${workspace.company_id} so removing from workspace ${workspace.id}`,
|
||||
);
|
||||
this.removeUser({ workspaceId: workspace.id, userId: userPk.id }, companyId, context).then(
|
||||
() => null,
|
||||
);
|
||||
await this.removeUser(
|
||||
{ workspaceId: workspace.id, userId: userPk.id },
|
||||
companyId,
|
||||
context,
|
||||
).then(() => null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user