Commit Graph

2 Commits

Author SHA1 Message Date
6c9b8ad3a8 Limit repeated access code requests via caching
Introduced a mechanism to limit repeated access code requests
within a configurable time period using `IMemoryCache` and a
new `RepeatRequestBlockingPeriod` configuration in
`SendAccessCodeParams`.

Key changes:
- Added `SendAccessCodeParams` configuration to `appsettings.json`.
- Updated DI in `DependencyInjection.cs` to include `SendAccessCodeParams`.
- Enhanced `SendAccessCodeCommand` with `MultipleRequestsAllowed`.
- Updated `SendAccessCodeCommandHandler` to handle caching logic:
  - Added `IsAccessCodeRequestsDisabled` and `DisableAccessCodeRequests`.
- Modified `AuthController` to support `autoGenerated` query parameter.
- Improved error handling and documentation.

These changes ensure better control over access code requests
and prevent abuse by limiting repeated requests within a
configurable time window.
2026-11-16 13:11:31 +01:00
fd2b21a73c Refactor access code request logic with MediatR
Encapsulated the access code request logic in a new `SendAccessCodeCommand` using MediatR. Introduced a `SendAccessCodeResult` enum to standardize outcomes. Refactored `AuthController` to delegate access code handling to the command, simplifying the controller and reducing dependencies.

Updated `AuthService` to map HTTP responses to `SendAccessCodeResult`. Improved error handling and edge case management in `SendAccessCodeCommandHandler`. Centralized history recording and notification logic in the command handler for better maintainability and separation of concerns.
2026-11-16 11:18:14 +01:00