feat: implement #736, #737, #738, #739 - reactivation rate-limit, audit log, redactEmail helper#850
Merged
Conversation
…Chain#739 MettaChain#736 - Use constant-time comparison (already implemented) MettaChain#737 - Rate-limit /users/me/reactivate to 5 requests/hour/email MettaChain#738 - Add audit log entry for account reactivation MettaChain#739 - Create reusable redactEmail helper
|
@Tyler7x Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #736, Closes #737, Closes #738, Closes #739
#736 - Use constant-time comparison for reactivation token verification
Already implemented in #735 - uses crypto.timingSafeEqual to compare the hashed token from the database against a SHA-256 hash of the provided token.
#737 - Rate-limit /users/me/reactivate to 5 requests per hour per email
Added in-memory rate limiter in UsersController that tracks reactivation attempts by email. Returns 429 Too Many Requests after 5 attempts within a 1-hour window.
#738 - Add audit log entry for account reactivation attempts
Added prisma.activityLog.create call in UsersService.reactivate() with action "REACTIVATE" and entity type "USER".
#739 - Introduce redactEmail helper and use in all log lines
Created exported redactEmail(email: string): string in security.utils.ts that returns createSha256(email).slice(0, 8). Updated log lines in auth.service.ts, users.service.ts, and login-rate-limit.service.ts to use redactEmail instead of raw email addresses.