mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
Reading List Change (#972)
* Allow an admin to delete another user's reading list * Allow an admin to delete another user's reading list
This commit is contained in:
parent
1dd6e054c6
commit
1a0fd3445d
@ -164,12 +164,15 @@ namespace API.Controllers
|
||||
public async Task<ActionResult> DeleteList([FromQuery] int readingListId)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserWithReadingListsByUsernameAsync(User.GetUsername());
|
||||
var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
|
||||
var readingList = user.ReadingLists.SingleOrDefault(r => r.Id == readingListId);
|
||||
if (readingList == null)
|
||||
if (readingList == null && !isAdmin)
|
||||
{
|
||||
return BadRequest("User is not associated with this reading list");
|
||||
}
|
||||
|
||||
readingList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(readingListId);
|
||||
|
||||
user.ReadingLists.Remove(readingList);
|
||||
|
||||
if (_unitOfWork.HasChanges() && await _unitOfWork.CommitAsync())
|
||||
@ -211,7 +214,7 @@ namespace API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the properites (title, summary) of a reading list
|
||||
/// Update the properties (title, summary) of a reading list
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
|
Loading…
x
Reference in New Issue
Block a user