mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05:00 
			
		
		
		
	Prevent unlogged users to try to see a watchlist
This commit is contained in:
		
							parent
							
								
									5cffeea4fd
								
							
						
					
					
						commit
						01d7f62c36
					
				@ -21,8 +21,10 @@ using System.Threading.Tasks;
 | 
				
			|||||||
using Kyoo.Abstractions.Controllers;
 | 
					using Kyoo.Abstractions.Controllers;
 | 
				
			||||||
using Kyoo.Abstractions.Models;
 | 
					using Kyoo.Abstractions.Models;
 | 
				
			||||||
using Kyoo.Abstractions.Models.Attributes;
 | 
					using Kyoo.Abstractions.Models.Attributes;
 | 
				
			||||||
 | 
					using Kyoo.Abstractions.Models.Exceptions;
 | 
				
			||||||
using Kyoo.Abstractions.Models.Permissions;
 | 
					using Kyoo.Abstractions.Models.Permissions;
 | 
				
			||||||
using Kyoo.Abstractions.Models.Utils;
 | 
					using Kyoo.Abstractions.Models.Utils;
 | 
				
			||||||
 | 
					using Kyoo.Authentication;
 | 
				
			||||||
using Microsoft.AspNetCore.Http;
 | 
					using Microsoft.AspNetCore.Http;
 | 
				
			||||||
using Microsoft.AspNetCore.Mvc;
 | 
					using Microsoft.AspNetCore.Mvc;
 | 
				
			||||||
using static Kyoo.Abstractions.Models.Utils.Constants;
 | 
					using static Kyoo.Abstractions.Models.Utils.Constants;
 | 
				
			||||||
@ -36,15 +38,9 @@ namespace Kyoo.Core.Api
 | 
				
			|||||||
	[ApiController]
 | 
						[ApiController]
 | 
				
			||||||
	[PartialPermission("LibraryItem")]
 | 
						[PartialPermission("LibraryItem")]
 | 
				
			||||||
	[ApiDefinition("News", Group = ResourcesGroup)]
 | 
						[ApiDefinition("News", Group = ResourcesGroup)]
 | 
				
			||||||
	public class WatchlistApi : BaseApi
 | 
						[UserOnly]
 | 
				
			||||||
 | 
						public class WatchlistApi(IWatchStatusRepository repository) : BaseApi
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		private readonly IWatchStatusRepository _repository;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public WatchlistApi(IWatchStatusRepository repository)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			_repository = repository;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/// <summary>
 | 
							/// <summary>
 | 
				
			||||||
		/// Get all
 | 
							/// Get all
 | 
				
			||||||
		/// </summary>
 | 
							/// </summary>
 | 
				
			||||||
@ -66,11 +62,9 @@ namespace Kyoo.Core.Api
 | 
				
			|||||||
			[FromQuery] Include<IWatchlist>? fields
 | 
								[FromQuery] Include<IWatchlist>? fields
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ICollection<IWatchlist> resources = await _repository.GetAll(
 | 
								if (User.GetId() == null)
 | 
				
			||||||
				filter,
 | 
									throw new UnauthorizedException();
 | 
				
			||||||
				fields,
 | 
								ICollection<IWatchlist> resources = await repository.GetAll(filter, fields, pagination);
 | 
				
			||||||
				pagination
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return Page(resources, pagination.Limit);
 | 
								return Page(resources, pagination.Limit);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user