Update API to follow REST
This commit is contained in:
@@ -3,7 +3,6 @@ using BoredCareers.Controllers.Payment;
|
||||
using BoredCareers.Services;
|
||||
using BoredCareers.Services.DatabaseService;
|
||||
using System.Threading.RateLimiting;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Stripe;
|
||||
using System.Security.Claims;
|
||||
|
||||
@@ -99,10 +98,9 @@ builder.Services.AddCors(o => o.AddDefaultPolicy(builder => {
|
||||
|
||||
builder.Services.AddRateLimiter(options => {
|
||||
options.AddPolicy("PerUserPolicy", httpContext => {
|
||||
// Identify the user (assumes authenticated user with NameIdentifier claim)
|
||||
var userId = httpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value
|
||||
?? httpContext.User.Identity?.Name
|
||||
?? httpContext.Connection.RemoteIpAddress?.ToString();
|
||||
var userId = httpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value
|
||||
?? httpContext.User.Identity?.Name
|
||||
?? httpContext.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
return RateLimitPartition.GetTokenBucketLimiter(userId, key => new TokenBucketRateLimiterOptions {
|
||||
TokenLimit = 10, // max 10 requests
|
||||
|
||||
Reference in New Issue
Block a user