Files
outline/server/queues/processors/UserDeletedProcessor.ts
T
Tom Moor a06671e8ce OAuth provider (#8884)
This PR contains the necessary work to make Outline an OAuth provider including:

- OAuth app registration
- OAuth app management
- Private / public apps (Public in cloud only)
- Full OAuth 2.0 spec compatible authentication flow
- Granular scopes
- User token management screen in settings
- Associated API endpoints for programatic access
2025-05-03 19:40:18 -04:00

65 lines
1.4 KiB
TypeScript

import {
ApiKey,
GroupUser,
OAuthAuthentication,
Star,
Subscription,
UserAuthentication,
UserMembership,
} from "@server/models";
import { sequelize } from "@server/storage/database";
import { Event as TEvent, UserEvent } from "@server/types";
import BaseProcessor from "./BaseProcessor";
export default class UserDeletedProcessor extends BaseProcessor {
static applicableEvents: TEvent["name"][] = ["users.delete"];
async perform(event: UserEvent) {
await sequelize.transaction(async (transaction) => {
await GroupUser.destroy({
where: {
userId: event.userId,
},
transaction,
individualHooks: true,
});
await UserAuthentication.destroy({
where: {
userId: event.userId,
},
transaction,
});
await UserMembership.destroy({
where: {
userId: event.userId,
},
transaction,
});
await Subscription.destroy({
where: {
userId: event.userId,
},
transaction,
});
await ApiKey.destroy({
where: {
userId: event.userId,
},
transaction,
});
await OAuthAuthentication.destroy({
where: {
userId: event.userId,
},
transaction,
});
await Star.destroy({
where: {
userId: event.userId,
},
transaction,
});
});
}
}