mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 11:12:44 +00:00
s3: require pro subscription to upload files
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Notesnook.API.Authorization
|
||||
{
|
||||
public class ProUserRequirement : AuthorizationHandler<ProUserRequirement>, IAuthorizationRequirement
|
||||
{
|
||||
private string[] allowedClaims = { "trial", "premium", "premium_canceled" };
|
||||
private readonly string[] allowedClaims = { "trial", "premium", "premium_canceled" };
|
||||
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, ProUserRequirement requirement)
|
||||
{
|
||||
var isProOrTrial = context.User.HasClaim((c) => c.Type == "notesnook:status" && allowedClaims.Contains(c.Value));
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Notesnook.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("s3")]
|
||||
[Authorize("Sync")]
|
||||
[Authorize("Pro")]
|
||||
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
|
||||
public class S3Controller : ControllerBase
|
||||
{
|
||||
@@ -101,8 +101,6 @@ namespace Notesnook.API.Controllers
|
||||
{
|
||||
var userId = this.User.FindFirstValue("sub");
|
||||
var size = await S3Service.GetObjectSizeAsync(userId, name);
|
||||
if (size == null) return BadRequest();
|
||||
|
||||
HttpContext.Response.Headers.ContentLength = size;
|
||||
return Ok();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user