mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-03 19:17:16 -05:00 
			
		
		
		
	Adding searchs for a specific ressource
This commit is contained in:
		
							parent
							
								
									e2cbbfcd17
								
							
						
					
					
						commit
						23f0b456ba
					
				@ -38,6 +38,9 @@ namespace Kyoo.CommonApi
 | 
			
		||||
 | 
			
		||||
			foreach ((string key, string desired) in where)
 | 
			
		||||
			{
 | 
			
		||||
				if (key == null || desired == null)
 | 
			
		||||
					throw new ArgumentException("Invalid key/value pair. Can't be null.");
 | 
			
		||||
				
 | 
			
		||||
				string value = desired;
 | 
			
		||||
				string operand = "eq";
 | 
			
		||||
				if (desired.Contains(':'))
 | 
			
		||||
 | 
			
		||||
@ -174,13 +174,13 @@ namespace Kyoo
 | 
			
		||||
 | 
			
		||||
			app.UseRouting();
 | 
			
		||||
 | 
			
		||||
			app.UseCookiePolicy(new CookiePolicyOptions 
 | 
			
		||||
			{
 | 
			
		||||
				MinimumSameSitePolicy = SameSiteMode.Strict
 | 
			
		||||
			});
 | 
			
		||||
			app.UseAuthentication();
 | 
			
		||||
			app.UseIdentityServer();
 | 
			
		||||
			app.UseAuthorization();
 | 
			
		||||
			app.UseCookiePolicy(new CookiePolicyOptions 
 | 
			
		||||
			{
 | 
			
		||||
				MinimumSameSitePolicy = SameSiteMode.Lax
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
			app.UseEndpoints(endpoints =>
 | 
			
		||||
			{
 | 
			
		||||
 | 
			
		||||
@ -79,7 +79,9 @@ namespace Kyoo.Api
 | 
			
		||||
		private readonly IConfiguration _configuration;
 | 
			
		||||
		private readonly string _picturePath;
 | 
			
		||||
 | 
			
		||||
		public AccountController(UserManager<User> userManager, SignInManager<User> siginInManager, IConfiguration configuration)
 | 
			
		||||
		public AccountController(UserManager<User> userManager, 
 | 
			
		||||
			SignInManager<User> siginInManager, 
 | 
			
		||||
			IConfiguration configuration)
 | 
			
		||||
		{
 | 
			
		||||
			_userManager = userManager;
 | 
			
		||||
			_signInManager = siginInManager;
 | 
			
		||||
@ -115,10 +117,11 @@ namespace Kyoo.Api
 | 
			
		||||
		{
 | 
			
		||||
			if (!ModelState.IsValid)
 | 
			
		||||
				return BadRequest(login);
 | 
			
		||||
			SignInResult result = await _signInManager.PasswordSignInAsync(login.Username, login.Password, login.StayLoggedIn, false);
 | 
			
		||||
			if (!result.Succeeded)
 | 
			
		||||
				return BadRequest(new [] { new {code = "InvalidCredentials", description = "Invalid username/password"}});
 | 
			
		||||
			SignInResult result = await _signInManager
 | 
			
		||||
				.PasswordSignInAsync(login.Username, login.Password, login.StayLoggedIn, false);
 | 
			
		||||
			if (result.Succeeded)
 | 
			
		||||
				return Ok();
 | 
			
		||||
			return BadRequest(new [] { new {code = "InvalidCredentials", description = "Invalid username/password"}});
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpPost("otac-login")]
 | 
			
		||||
@ -194,11 +197,9 @@ namespace Kyoo.Api
 | 
			
		||||
			if (data.Picture?.Length > 0)
 | 
			
		||||
			{
 | 
			
		||||
				string path = Path.Combine(_picturePath, user.Id);
 | 
			
		||||
				await using (FileStream file = System.IO.File.Create(path))
 | 
			
		||||
				{
 | 
			
		||||
				await using FileStream file = System.IO.File.Create(path);
 | 
			
		||||
				await data.Picture.CopyToAsync(file);
 | 
			
		||||
			}
 | 
			
		||||
			}
 | 
			
		||||
			await _userManager.UpdateAsync(user);
 | 
			
		||||
			return Ok();
 | 
			
		||||
		}
 | 
			
		||||
@ -1,4 +1,5 @@
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Kyoo.Controllers;
 | 
			
		||||
using Kyoo.Models;
 | 
			
		||||
using Microsoft.AspNetCore.Authorization;
 | 
			
		||||
@ -32,5 +33,52 @@ namespace Kyoo.Api
 | 
			
		||||
				Studios = await _libraryManager.SearchStudios(query)
 | 
			
		||||
			};
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/collection")]
 | 
			
		||||
		[HttpGet("{query}/collections")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<Collection>> SearchCollections(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchCollections(query);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/show")]
 | 
			
		||||
		[HttpGet("{query}/shows")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<Show>> SearchShows(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchShows(query);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/episode")]
 | 
			
		||||
		[HttpGet("{query}/episodes")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<Episode>> SearchEpisodes(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchEpisodes(query);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/people")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<People>> SearchPeople(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchPeople(query);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/genre")]
 | 
			
		||||
		[HttpGet("{query}/genres")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<Genre>> SearchGenres(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchGenres(query);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		[HttpGet("{query}/studio")]
 | 
			
		||||
		[HttpGet("{query}/studios")]
 | 
			
		||||
		[Authorize(Policy="Read")]
 | 
			
		||||
		public Task<ICollection<Studio>> SearchStudios(string query)
 | 
			
		||||
		{
 | 
			
		||||
			return _libraryManager.SearchStudios(query);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
Subproject commit 7a9808719933a092e56fc26be8f5c40bf7894e7c
 | 
			
		||||
Subproject commit c7f916c9c9f8094275ea5505cd2d77fe7a98c682
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user