using System.Collections.Generic; using Kavita.Models.Entities.Progress; namespace Kavita.API.Store; public interface IUserContext { /// /// Gets the current authenticated user's ID. /// Returns null if user is not authenticated or on [AllowAnonymous] endpoint. /// int? GetUserId(); /// /// Gets the current authenticated user's ID. /// Throws KavitaException if user is not authenticated. /// int GetUserIdOrThrow(); /// /// Gets the current authenticated user's username. /// Returns null if user is not authenticated. /// /// Warning! Username's can contain .. and /, do not use folders or filenames explicitly with the Username string? GetUsername(); /// /// The Roles associated with the Authenticated user /// IReadOnlyList Roles { get; } /// /// Returns true if the current user is authenticated. /// bool IsAuthenticated { get; } /// /// Gets the authentication method used (JWT, Auth Key, OIDC). /// AuthenticationType GetAuthenticationType(); bool HasRole(string role); bool HasAnyRole(params string[] roles); bool HasAllRoles(params string[] roles); }