Reduce Unauthenticated Errors in Sentry (#238)
* Updated README to be explicit that kavita.db needs to be writable. * Implemented a new Exception type that is for throwing a message to UI without logging in Sentry.
This commit is contained in:
parent
0a39a17407
commit
aaad82cb7a
4 changed files with 27 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Security.Claims;
|
||||
using Kavita.Common;
|
||||
|
||||
namespace API.Extensions
|
||||
{
|
||||
|
@ -6,7 +7,9 @@ namespace API.Extensions
|
|||
{
|
||||
public static string GetUsername(this ClaimsPrincipal user)
|
||||
{
|
||||
return user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
var userClaim = user.FindFirst(ClaimTypes.NameIdentifier);
|
||||
if (userClaim == null) throw new KavitaException("User is not authenticated");
|
||||
return userClaim.Value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue