mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 10:37:04 -04:00 
			
		
		
		
	* 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.
		
			
				
	
	
		
			15 lines
		
	
	
		
			431 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
		
			431 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Security.Claims;
 | |
| using Kavita.Common;
 | |
| 
 | |
| namespace API.Extensions
 | |
| {
 | |
|     public static class ClaimsPrincipalExtensions
 | |
|     {
 | |
|         public static string GetUsername(this ClaimsPrincipal user)
 | |
|         {
 | |
|             var userClaim = user.FindFirst(ClaimTypes.NameIdentifier);
 | |
|             if (userClaim == null) throw new KavitaException("User is not authenticated");
 | |
|             return userClaim.Value;
 | |
|         }
 | |
|     }
 | |
| } |