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

This commit is contained in:
Joseph Milazzo 2021-01-02 09:25:45 -06:00
parent 521eac266a
commit 55a44000fc
2 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -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));
}
}
}