diff --git a/src/Framework.SecuritySystem/UserSource/ICurrentUserSource.cs b/src/Framework.SecuritySystem.Abstract/UserSource/ICurrentUserSource.cs similarity index 100% rename from src/Framework.SecuritySystem/UserSource/ICurrentUserSource.cs rename to src/Framework.SecuritySystem.Abstract/UserSource/ICurrentUserSource.cs diff --git a/src/Framework.SecuritySystem/UserSource/CurrentUserSource.cs b/src/Framework.SecuritySystem/UserSource/CurrentUserSource.cs index 3e85f045a..aac4fe0d0 100644 --- a/src/Framework.SecuritySystem/UserSource/CurrentUserSource.cs +++ b/src/Framework.SecuritySystem/UserSource/CurrentUserSource.cs @@ -2,23 +2,9 @@ namespace Framework.SecuritySystem.UserSource; -public class CurrentUserSource : ICurrentUserSource +public class CurrentUserSource(ICurrentUser currentUser, IUserSource userSource) : ICurrentUserSource { - private readonly Lazy lazyCurrentUser; - - private readonly Lazy lazyCurrentUserId; - - public CurrentUserSource( - IUserSource userSource, - UserPathInfo userPathInfo, - ICurrentUser currentUser) - { - this.lazyCurrentUser = LazyHelper.Create(() => userSource.GetByName(currentUser.Name)); - - this.lazyCurrentUserId = LazyHelper.Create(() => userPathInfo.IdPath.Eval(this.CurrentUser)); - } + private readonly Lazy lazyCurrentUser = LazyHelper.Create(() => userSource.GetByName(currentUser.Name)); public TUser CurrentUser => this.lazyCurrentUser.Value; - - public Guid CurrentUserId => this.lazyCurrentUserId.Value; } diff --git a/src/Framework.SecuritySystem/UserSource/UserSource.cs b/src/Framework.SecuritySystem/UserSource/UserSource.cs index 4a0f35067..05b276821 100644 --- a/src/Framework.SecuritySystem/UserSource/UserSource.cs +++ b/src/Framework.SecuritySystem/UserSource/UserSource.cs @@ -7,23 +7,19 @@ public class UserSource(IQueryableSource queryableSource, UserPathInfo this.GetQueryable(name).SingleOrDefault(); - public TUser GetByName(string name) - { - return this.TryGetByName(name) ?? throw this.GetNotFoundException(name); - } + public TUser GetByName(string name) => this.TryGetByName(name) ?? throw this.GetNotFoundException(name); - public Guid? TryGetId(string name) => - this.GetQueryable(name) - .Select(userPathInfo.IdPath) - .Select(v => (Guid?)v).SingleOrDefault(); + public Guid? TryGetId(string name) => this.GetQueryable(name).Select(userPathInfo.IdPath).Select(v => (Guid?)v).SingleOrDefault(); public Guid GetId(string name) => this.TryGetId(name) ?? throw this.GetNotFoundException(name); - private IQueryable GetQueryable(string name) => queryableSource.GetQueryable() - .Where(userPathInfo.Filter) - .Where(userPathInfo.NamePath.Select(objName => objName == name)); + private IQueryable GetQueryable(string name) => + queryableSource + .GetQueryable() + .Where(userPathInfo.Filter) + .Where(userPathInfo.NamePath.Select(objName => objName == name)); private Exception GetNotFoundException(string name) => new UserSourceException($"{typeof(TUser).Name} \"{name}\" not found"); } diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index 41ea38be6..37c226f27 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2024")] -[assembly: AssemblyVersion("22.3.10.0")] -[assembly: AssemblyFileVersion("22.3.10.0")] -[assembly: AssemblyInformationalVersion("22.3.10.0")] +[assembly: AssemblyVersion("22.3.11.0")] +[assembly: AssemblyFileVersion("22.3.11.0")] +[assembly: AssemblyInformationalVersion("22.3.11.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]