feat: add scheduled refresh token and password reset cleanup job#114
Open
GitAddRemote wants to merge 2 commits intomainfrom
Open
feat: add scheduled refresh token and password reset cleanup job#114GitAddRemote wants to merge 2 commits intomainfrom
GitAddRemote wants to merge 2 commits intomainfrom
Conversation
Add TokenCleanupService to the auth module with a @Cron job that runs daily at 3am (configurable via REFRESH_TOKEN_CLEANUP_CRON) and deletes all refresh_tokens rows where revoked=true or expires_at < now, and all password_resets rows where used=true or expires_at < now. - Job skips early when NODE_ENV=test - Logs row count and duration on success, error stack on failure - Does not rethrow on failure so job errors cannot crash the process - ScheduleModule is already conditionally excluded in test env (AppModule) Closes #98
Co-authored-with: ISSUE-98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TokenCleanupServiceto the auth module with a@Cronjob (default:0 3 * * *— 3am daily)refresh_tokensrows whererevoked = trueORexpires_at < NOW()password_resetsrows whereused = trueORexpires_at < NOW()REFRESH_TOKEN_CLEANUP_CRONenv varNODE_ENV=test;ScheduleModuleis already excluded in test env viaAppModuleTest plan
REFRESH_TOKEN_CLEANUP_CRON="* * * * *"locally and confirm log output after 1 minuteREFRESH_TOKEN_CLEANUP_CRONdocumented in.env.exampleCloses #98