mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-10-01 18:49:42 +02:00
global: add null safety checks
This commit is contained in:
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.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user