mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
a06671e8ce
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
34 lines
887 B
TypeScript
34 lines
887 B
TypeScript
import { subMonths } from "date-fns";
|
|
import { Op } from "sequelize";
|
|
import Logger from "@server/logging/Logger";
|
|
import { OAuthAuthorizationCode } from "@server/models";
|
|
import BaseTask, { TaskPriority, TaskSchedule } from "./BaseTask";
|
|
|
|
type Props = Record<string, never>;
|
|
|
|
export default class CleanupOAuthAuthorizationCodeTask extends BaseTask<Props> {
|
|
static cron = TaskSchedule.Day;
|
|
|
|
public async perform() {
|
|
Logger.info(
|
|
"task",
|
|
`Deleting OAuth authorization codes older than one month…`
|
|
);
|
|
const count = await OAuthAuthorizationCode.destroy({
|
|
where: {
|
|
expiresAt: {
|
|
[Op.lt]: subMonths(new Date(), 1),
|
|
},
|
|
},
|
|
});
|
|
Logger.info("task", `${count} expired OAuth authorization codes deleted.`);
|
|
}
|
|
|
|
public get options() {
|
|
return {
|
|
attempts: 1,
|
|
priority: TaskPriority.Background,
|
|
};
|
|
}
|
|
}
|