mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-03 19:17:05 -05: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;
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |