global: add null safety checks

This commit is contained in:
Abdullah Atta committed 2025-10-14 21:15:51 +05:00
1 parent be432dfd24
commit 6e35edb715
109 files changed
+452 -590

No files matched your search

@@ -10,5 +10,8 @@ namespace System.Security.Claims
private readonly static string[] SUBSCRIBED_CLAIMS = ["believer", "education", "essential", "pro", "legacy_pro"];
public static bool IsUserSubscribed(this ClaimsPrincipal user)
=> user.Claims.Any((c) => c.Type == "notesnook:status" && SUBSCRIBED_CLAIMS.Contains(c.Value));
public static string GetUserId(this ClaimsPrincipal user)
=> user.FindFirstValue("sub") ?? throw new Exception("User ID not found in claims.");
}
}