diff --git a/API/Controllers/KoreaderController.cs b/API/Controllers/KoreaderController.cs index 5fec418cb..7c46ec1f3 100644 --- a/API/Controllers/KoreaderController.cs +++ b/API/Controllers/KoreaderController.cs @@ -19,8 +19,7 @@ namespace API.Controllers; /// The endpoint to interface with Koreader's Progress Sync plugin. /// /// -/// Koreader uses a different form of athentication. It stores the user name -/// and password in headers. +/// Koreader uses a different form of authentication. It stores the username and password in headers. /// /// [AllowAnonymous] @@ -55,6 +54,7 @@ public class KoreaderController : BaseApiController { var userId = await GetUserId(apiKey); var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId); + if (user == null) return Unauthorized(); return Ok(new { username = user.UserName }); } @@ -66,12 +66,12 @@ public class KoreaderController : BaseApiController _logger.LogDebug("Koreader sync progress: {Progress}", request.Progress); var userId = await GetUserId(apiKey); await _koreaderService.SaveProgress(request, userId); - + return Ok(new { document = request.Document, timestamp = DateTime.UtcNow }); } [HttpGet("{apiKey}/syncs/progress/{ebookHash}")] - public async Task GetProgress(string apiKey, string ebookHash) + public async Task> GetProgress(string apiKey, string ebookHash) { var userId = await GetUserId(apiKey); var response = await _koreaderService.GetProgress(ebookHash, userId);