Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Changed scan to POST and added new API for route gurads on UI.

Joseph Milazzo55a44000fcc2
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index e06cba530..b87e75cbf 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -85,7 +85,7 @@ namespace API.Controllers
}
[Authorize(Policy = "RequireAdminRole")]
- [HttpGet("scan")]
+ [HttpPost("scan")]
public async Task<ActionResult> ScanLibrary(int libraryId)
{
var library = await _libraryRepository.GetLibraryDtoForIdAsync(libraryId);
diff --git a/API/Controllers/UsersController.cs b/API/Controllers/UsersController.cs
index db81af51d..a332c88c9 100644
--- a/API/Controllers/UsersController.cs
+++ b/API/Controllers/UsersController.cs
@@ -84,5 +84,17 @@ namespace API.Controllers
{
return Ok(await _userRepository.GetMembersAsync());
}
+
+ [HttpGet("has-library-access")]
+ public async Task<ActionResult<bool>> HasLibraryAccess(int libraryId)
+ {
+ var user = await _userRepository.GetUserByUsernameAsync(User.GetUsername());
+
+ if (user == null) return BadRequest("Could not validate user");
+
+ var libs = await _libraryRepository.GetLibrariesForUsernameAysnc(user.UserName);
+
+ return Ok(libs.Any(x => x.Id == libraryId));
+ }
}
}
\ No newline at end of file