diff --git a/Kyoo.CommonAPI/ApiHelper.cs b/Kyoo.CommonAPI/ApiHelper.cs index 3ffa79d0..7aaef2f8 100644 --- a/Kyoo.CommonAPI/ApiHelper.cs +++ b/Kyoo.CommonAPI/ApiHelper.cs @@ -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(':')) diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index d6ff4004..12e1515c 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -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 => { diff --git a/Kyoo/Views/API/AccountAPI.cs b/Kyoo/Views/API/AccountApi.cs similarity index 92% rename from Kyoo/Views/API/AccountAPI.cs rename to Kyoo/Views/API/AccountApi.cs index 80eea5f0..dc02fcda 100644 --- a/Kyoo/Views/API/AccountAPI.cs +++ b/Kyoo/Views/API/AccountApi.cs @@ -79,7 +79,9 @@ namespace Kyoo.Api private readonly IConfiguration _configuration; private readonly string _picturePath; - public AccountController(UserManager userManager, SignInManager siginInManager, IConfiguration configuration) + public AccountController(UserManager userManager, + SignInManager 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"}}); - return Ok(); + 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,10 +197,8 @@ 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 data.Picture.CopyToAsync(file); - } + await using FileStream file = System.IO.File.Create(path); + await data.Picture.CopyToAsync(file); } await _userManager.UpdateAsync(user); return Ok(); diff --git a/Kyoo/Views/API/SearchApi.cs b/Kyoo/Views/API/SearchApi.cs index 20c4297d..c253adfd 100644 --- a/Kyoo/Views/API/SearchApi.cs +++ b/Kyoo/Views/API/SearchApi.cs @@ -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> SearchCollections(string query) + { + return _libraryManager.SearchCollections(query); + } + + [HttpGet("{query}/show")] + [HttpGet("{query}/shows")] + [Authorize(Policy="Read")] + public Task> SearchShows(string query) + { + return _libraryManager.SearchShows(query); + } + + [HttpGet("{query}/episode")] + [HttpGet("{query}/episodes")] + [Authorize(Policy="Read")] + public Task> SearchEpisodes(string query) + { + return _libraryManager.SearchEpisodes(query); + } + + [HttpGet("{query}/people")] + [Authorize(Policy="Read")] + public Task> SearchPeople(string query) + { + return _libraryManager.SearchPeople(query); + } + + [HttpGet("{query}/genre")] + [HttpGet("{query}/genres")] + [Authorize(Policy="Read")] + public Task> SearchGenres(string query) + { + return _libraryManager.SearchGenres(query); + } + + [HttpGet("{query}/studio")] + [HttpGet("{query}/studios")] + [Authorize(Policy="Read")] + public Task> SearchStudios(string query) + { + return _libraryManager.SearchStudios(query); + } } } \ No newline at end of file diff --git a/Kyoo/Views/WebClient b/Kyoo/Views/WebClient index 7a980871..c7f916c9 160000 --- a/Kyoo/Views/WebClient +++ b/Kyoo/Views/WebClient @@ -1 +1 @@ -Subproject commit 7a9808719933a092e56fc26be8f5c40bf7894e7c +Subproject commit c7f916c9c9f8094275ea5505cd2d77fe7a98c682