From 4a15fa8363eccd79b263ff1b567195483591f6f4 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 24 Jan 2021 23:11:26 +0100 Subject: [PATCH] Finding the issue in the validator of the local repository's edit --- Kyoo.Common/.gitignore | 1 - Kyoo.Common/Utility.cs | 2 ++ Kyoo.CommonAPI/LocalRepository.cs | 4 +++- Kyoo/.gitignore | 1 - Kyoo/Startup.cs | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Kyoo.Common/.gitignore b/Kyoo.Common/.gitignore index 877ccf42..8f7864db 100644 --- a/Kyoo.Common/.gitignore +++ b/Kyoo.Common/.gitignore @@ -136,7 +136,6 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj diff --git a/Kyoo.Common/Utility.cs b/Kyoo.Common/Utility.cs index e4f7d14d..94e69a51 100644 --- a/Kyoo.Common/Utility.cs +++ b/Kyoo.Common/Utility.cs @@ -191,6 +191,8 @@ namespace Kyoo throw new ArgumentNullException(nameof(obj)); if (genericType == null) throw new ArgumentNullException(nameof(genericType)); + if (!genericType.IsGenericType) + throw new ArgumentException($"{nameof(genericType)} is not a generic type."); IEnumerable types = genericType.IsInterface ? obj.GetType().GetInterfaces() diff --git a/Kyoo.CommonAPI/LocalRepository.cs b/Kyoo.CommonAPI/LocalRepository.cs index 381bfb44..674c7239 100644 --- a/Kyoo.CommonAPI/LocalRepository.cs +++ b/Kyoo.CommonAPI/LocalRepository.cs @@ -231,8 +231,10 @@ namespace Kyoo.Controllers foreach (PropertyInfo property in typeof(T).GetProperties() .Where(x => typeof(IEnumerable).IsAssignableFrom(x.PropertyType) - && !typeof(string).IsAssignableFrom(x.PropertyType))) + && !typeof(string).IsAssignableFrom(x.PropertyType)) { + // TODO For DE classes (like ShowDE), the basic ienumerable should not be verified (for exemple, GenreLinks should be checked & not Genres). + Console.WriteLine($"Validating {property.Name}"); object value = property.GetValue(resource); if (value == null || value is ICollection || Utility.IsOfGenericType(value, typeof(ICollection<>))) continue; diff --git a/Kyoo/.gitignore b/Kyoo/.gitignore index 0b25db41..8f2daad7 100644 --- a/Kyoo/.gitignore +++ b/Kyoo/.gitignore @@ -138,7 +138,6 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index 990b714e..e9a17eab 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -112,7 +112,7 @@ namespace Kyoo services.AddAuthorization(options => { - AuthorizationPolicyBuilder scheme = new AuthorizationPolicyBuilder(IdentityConstants.ApplicationScheme, JwtBearerDefaults.AuthenticationScheme); + AuthorizationPolicyBuilder scheme = new(IdentityConstants.ApplicationScheme, JwtBearerDefaults.AuthenticationScheme); options.DefaultPolicy = scheme.RequireAuthenticatedUser().Build(); string[] permissions = {"Read", "Write", "Play", "Admin"};