diff --git a/Notesnook.API/Authorization/SyncRequirement.cs b/Notesnook.API/Authorization/SyncRequirement.cs index aec7cd5..eb9ccd2 100644 --- a/Notesnook.API/Authorization/SyncRequirement.cs +++ b/Notesnook.API/Authorization/SyncRequirement.cs @@ -29,15 +29,15 @@ namespace Notesnook.API.Authorization { public class SyncRequirement : AuthorizationHandler, IAuthorizationRequirement { - private Dictionary pathErrorPhraseMap = new Dictionary + private readonly Dictionary pathErrorPhraseMap = new Dictionary { ["/sync/attachments"] = "use attachments", ["/sync"] = "sync your notes", ["/hubs/sync"] = "sync your notes", + ["/hubs/sync/v2"] = "sync your notes", ["/monographs"] = "publish monographs" }; - private string[] allowedClaims = { "trial", "premium", "premium_canceled" }; protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, SyncRequirement requirement) { PathString path = context.Resource is DefaultHttpContext httpContext ? httpContext.Request.Path : null; @@ -45,7 +45,7 @@ namespace Notesnook.API.Authorization if (result.Succeeded) context.Succeed(requirement); else { - var hasReason = result.AuthorizationFailure.FailureReasons.Count() > 0; + var hasReason = result.AuthorizationFailure.FailureReasons.Any(); if (hasReason) context.Fail(result.AuthorizationFailure.FailureReasons.First()); else context.Fail(); @@ -60,7 +60,7 @@ namespace Notesnook.API.Authorization if (string.IsNullOrEmpty(id)) { - var reason = new AuthorizationFailureReason[] + var reason = new[] { new AuthorizationFailureReason(this, "Invalid token.") }; @@ -84,7 +84,7 @@ namespace Notesnook.API.Authorization } var error = $"Please confirm your email to {phrase}."; - var reason = new AuthorizationFailureReason[] + var reason = new[] { new AuthorizationFailureReason(this, error) }; @@ -92,7 +92,6 @@ namespace Notesnook.API.Authorization // context.Fail(new AuthorizationFailureReason(this, error)); } - var isProOrTrial = User.HasClaim((c) => c.Type == "notesnook:status" && allowedClaims.Contains(c.Value)); if (hasSyncScope && isInAudience && hasRole && isEmailVerified) return PolicyAuthorizationResult.Success(); //(requirement); return PolicyAuthorizationResult.Forbid();