From 9f51b41ae0822f77d974750164c06a950e549ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 23 Mar 2018 17:32:16 +0300 Subject: [PATCH] Moved Abp.Users to another module. --- Volo.Abp.sln | 7 --- .../Volo.Abp.Auditing.csproj | 2 +- .../Volo/Abp/Auditing/AbpAuditingModule.cs | 4 +- .../Extensions/Logging/LoggerExtensions.cs | 9 ++-- .../Volo.Abp.Ddd.Application.csproj | 2 +- .../Application/AbpDddApplicationModule.cs | 4 +- .../Volo/Abp/Users/CurrentUser.cs | 0 .../Volo/Abp/Users/CurrentUserExtensions.cs | 0 .../Volo/Abp/Users/ICurrentUser.cs | 0 src/Volo.Abp.Users/Volo.Abp.Users.csproj | 21 --------- .../Volo.Abp.Users.csproj.DotSettings | 2 - .../Settings/UserSettingManagerExtensions.cs | 43 ----------------- .../Volo/Abp/Users/AbpUsersModule.cs | 22 --------- .../Volo/Abp/Users/IUserInfo.cs | 22 --------- .../Volo/Abp/Users/IUserLookupService.cs | 14 ------ .../Volo/Abp/Users/NullUserLookupService.cs | 21 --------- src/Volo.Abp.Users/Volo/Abp/Users/UserInfo.cs | 38 --------------- .../Abp/Users/UserSettingValueProvider.cs | 47 ------------------- 18 files changed, 12 insertions(+), 246 deletions(-) rename src/{Volo.Abp.Users => Volo.Abp.Security}/Volo/Abp/Users/CurrentUser.cs (100%) rename src/{Volo.Abp.Users => Volo.Abp.Security}/Volo/Abp/Users/CurrentUserExtensions.cs (100%) rename src/{Volo.Abp.Users => Volo.Abp.Security}/Volo/Abp/Users/ICurrentUser.cs (100%) delete mode 100644 src/Volo.Abp.Users/Volo.Abp.Users.csproj delete mode 100644 src/Volo.Abp.Users/Volo.Abp.Users.csproj.DotSettings delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Settings/UserSettingManagerExtensions.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/AbpUsersModule.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/IUserInfo.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/IUserLookupService.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/NullUserLookupService.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/UserInfo.cs delete mode 100644 src/Volo.Abp.Users/Volo/Abp/Users/UserSettingValueProvider.cs diff --git a/Volo.Abp.sln b/Volo.Abp.sln index b7a602335d..9791fb908b 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -162,8 +162,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Ddd.Domain", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Ddd.Application", "src\Volo.Abp.Ddd.Application\Volo.Abp.Ddd.Application.csproj", "{5AB7E368-1CC8-401D-9952-6CA6779305E7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Users", "src\Volo.Abp.Users\Volo.Abp.Users.csproj", "{DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Auditing", "src\Volo.Abp.Auditing\Volo.Abp.Auditing.csproj", "{03F51721-DA51-4BAE-9909-3FC88FAB7774}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Auditing.Tests", "test\Volo.Abp.Auditing.Tests\Volo.Abp.Auditing.Tests.csproj", "{D5733D90-8C3D-4026-85E2-41DED26C4938}" @@ -454,10 +452,6 @@ Global {5AB7E368-1CC8-401D-9952-6CA6779305E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AB7E368-1CC8-401D-9952-6CA6779305E7}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AB7E368-1CC8-401D-9952-6CA6779305E7}.Release|Any CPU.Build.0 = Release|Any CPU - {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Release|Any CPU.Build.0 = Release|Any CPU {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Debug|Any CPU.Build.0 = Debug|Any CPU {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -543,7 +537,6 @@ Global {9FC49D82-04E5-4170-8618-682BD3350910} = {447C8A77-E5F0-4538-8687-7383196D04EA} {D1318094-7907-4826-B5F3-CFFC741F235F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {5AB7E368-1CC8-401D-9952-6CA6779305E7} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} - {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {03F51721-DA51-4BAE-9909-3FC88FAB7774} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {D5733D90-8C3D-4026-85E2-41DED26C4938} = {447C8A77-E5F0-4538-8687-7383196D04EA} EndGlobalSection diff --git a/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj b/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj index 04549d5441..bc627b6cb5 100644 --- a/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj +++ b/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj @@ -16,8 +16,8 @@ + - diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs index 13202af3fe..99b9cafe49 100644 --- a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs @@ -2,8 +2,8 @@ using Volo.Abp.Data; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; +using Volo.Abp.Security; using Volo.Abp.Timing; -using Volo.Abp.Users; namespace Volo.Abp.Auditing { @@ -11,7 +11,7 @@ namespace Volo.Abp.Auditing [DependsOn( typeof(AbpDataModule), typeof(AbpTimingModule), - typeof(AbpUsersModule), + typeof(AbpSecurityModule), typeof(AbpMultiTenancyAbstractionsModule) )] public class AbpAuditingModule : AbpModule diff --git a/src/Volo.Abp.Core/Microsoft/Extensions/Logging/LoggerExtensions.cs b/src/Volo.Abp.Core/Microsoft/Extensions/Logging/LoggerExtensions.cs index 76fe1a421f..e60e8ec6ca 100644 --- a/src/Volo.Abp.Core/Microsoft/Extensions/Logging/LoggerExtensions.cs +++ b/src/Volo.Abp.Core/Microsoft/Extensions/Logging/LoggerExtensions.cs @@ -56,11 +56,14 @@ namespace Microsoft.Extensions.Logging } } - public static void LogException(this ILogger logger, Exception ex) + public static void LogException(this ILogger logger, Exception ex, LogLevel? level = null) { - var logLevel = (ex as IHasLogLevel)?.LogLevel ?? LogLevel.Error; + logger.LogWithLevel( + level ?? (ex as IHasLogLevel)?.LogLevel ?? LogLevel.Error, + ex.Message, + ex + ); - logger.LogWithLevel(logLevel, ex.Message, ex); LogDetails(logger, ex); } diff --git a/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj b/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj index aaac4368a0..9d83c4ccf6 100644 --- a/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj +++ b/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/AbpDddApplicationModule.cs b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/AbpDddApplicationModule.cs index a8e04b8d0c..b3257d9470 100644 --- a/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/AbpDddApplicationModule.cs +++ b/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/AbpDddApplicationModule.cs @@ -7,13 +7,13 @@ using Volo.Abp.Http; using Volo.Abp.Http.Modeling; using Volo.Abp.Modularity; using Volo.Abp.ObjectMapping; -using Volo.Abp.Users; +using Volo.Abp.Security; using Volo.Abp.Validation; namespace Volo.Abp.Application { [DependsOn(typeof(AbpDddDomainModule))] - [DependsOn(typeof(AbpUsersModule))] + [DependsOn(typeof(AbpSecurityModule))] [DependsOn(typeof(AbpObjectMappingModule))] [DependsOn(typeof(AbpValidationModule))] [DependsOn(typeof(AbpAuthorizationModule))] diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/CurrentUser.cs b/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs similarity index 100% rename from src/Volo.Abp.Users/Volo/Abp/Users/CurrentUser.cs rename to src/Volo.Abp.Security/Volo/Abp/Users/CurrentUser.cs diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/CurrentUserExtensions.cs b/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs similarity index 100% rename from src/Volo.Abp.Users/Volo/Abp/Users/CurrentUserExtensions.cs rename to src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/ICurrentUser.cs b/src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs similarity index 100% rename from src/Volo.Abp.Users/Volo/Abp/Users/ICurrentUser.cs rename to src/Volo.Abp.Security/Volo/Abp/Users/ICurrentUser.cs diff --git a/src/Volo.Abp.Users/Volo.Abp.Users.csproj b/src/Volo.Abp.Users/Volo.Abp.Users.csproj deleted file mode 100644 index ae2e0bf249..0000000000 --- a/src/Volo.Abp.Users/Volo.Abp.Users.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - netstandard2.0 - Volo.Abp.Users - Volo.Abp.Users - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; - false - false - false - - - - - - - - - diff --git a/src/Volo.Abp.Users/Volo.Abp.Users.csproj.DotSettings b/src/Volo.Abp.Users/Volo.Abp.Users.csproj.DotSettings deleted file mode 100644 index 58ad6c8854..0000000000 --- a/src/Volo.Abp.Users/Volo.Abp.Users.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - CSharp71 \ No newline at end of file diff --git a/src/Volo.Abp.Users/Volo/Abp/Settings/UserSettingManagerExtensions.cs b/src/Volo.Abp.Users/Volo/Abp/Settings/UserSettingManagerExtensions.cs deleted file mode 100644 index 4e3a1dd574..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Settings/UserSettingManagerExtensions.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using JetBrains.Annotations; -using Volo.Abp.Users; - -namespace Volo.Abp.Settings -{ - //TODO: Consider to move to another package? - - public static class UserSettingManagerExtensions - { - public static Task GetOrNullForUserAsync(this ISettingManager settingManager, [NotNull] string name, Guid userId, bool fallback = true) - { - return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, userId.ToString(), fallback); - } - - public static Task GetOrNullForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) - { - return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, null, fallback); - } - - public static Task> GetAllForUserAsync(this ISettingManager settingManager, Guid userId, bool fallback = true) - { - return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, userId.ToString(), fallback); - } - - public static Task> GetAllForCurrentUserAsync(this ISettingManager settingManager, bool fallback = true) - { - return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, null, fallback); - } - - public static Task SetForUserAsync(this ISettingManager settingManager, Guid userId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) - { - return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, userId.ToString(), forceToSet); - } - - public static Task SetForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) - { - return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, null, forceToSet); - } - } -} diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/AbpUsersModule.cs b/src/Volo.Abp.Users/Volo/Abp/Users/AbpUsersModule.cs deleted file mode 100644 index c1a84bd44f..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/AbpUsersModule.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Modularity; -using Volo.Abp.Security; -using Volo.Abp.Settings; - -namespace Volo.Abp.Users -{ - [DependsOn(typeof(AbpSecurityModule))] - [DependsOn(typeof(AbpSettingsModule))] - public class AbpUsersModule : AbpModule - { - public override void ConfigureServices(IServiceCollection services) - { - services.Configure(options => - { - options.ValueProviders.Add(); - }); - - services.AddAssemblyOf(); - } - } -} diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/IUserInfo.cs b/src/Volo.Abp.Users/Volo/Abp/Users/IUserInfo.cs deleted file mode 100644 index f2b8940319..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/IUserInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using JetBrains.Annotations; - -namespace Volo.Abp.Users -{ - public interface IUserInfo - { - Guid Id { get; } - - string UserName { get; } - - [CanBeNull] - string Email { get; } - - bool EmailConfirmed { get; } - - [CanBeNull] - string PhoneNumber { get; } - - bool PhoneNumberConfirmed { get; } - } -} \ No newline at end of file diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/IUserLookupService.cs b/src/Volo.Abp.Users/Volo/Abp/Users/IUserLookupService.cs deleted file mode 100644 index 8265fd8250..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/IUserLookupService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace Volo.Abp.Users -{ - public interface IUserLookupService - { - Task FindByIdAsync(Guid id); - - Task FindByUserNameAsync(string userName); - - //TODO: Searching users... - } -} diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/NullUserLookupService.cs b/src/Volo.Abp.Users/Volo/Abp/Users/NullUserLookupService.cs deleted file mode 100644 index fbf170085b..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/NullUserLookupService.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.Users -{ - public class NullUserLookupService : IUserLookupService, ISingletonDependency - { - private static readonly Task NullUserResult = Task.FromResult((IUserInfo) null); - - public Task FindByIdAsync(Guid id) - { - return NullUserResult; - } - - public Task FindByUserNameAsync(string userName) - { - return NullUserResult; - } - } -} \ No newline at end of file diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/UserInfo.cs b/src/Volo.Abp.Users/Volo/Abp/Users/UserInfo.cs deleted file mode 100644 index 49eae3c878..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/UserInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using JetBrains.Annotations; - -namespace Volo.Abp.Users -{ - public class UserInfo : IUserInfo - { - public Guid Id { get; } - - public string UserName { get; } - - public string Email { get; } - - public bool EmailConfirmed { get; } - - public string PhoneNumber { get; } - - public bool PhoneNumberConfirmed { get; } - - public UserInfo( - Guid id, - [NotNull] string userName, - [CanBeNull] string email = null, - bool emailConfirmed = false, - [CanBeNull] string phoneNumber = null, - bool phoneNumberConfirmed = false) - { - Check.NotNull(userName, nameof(userName)); - - Id = id; - UserName = userName; - Email = email; - EmailConfirmed = emailConfirmed; - PhoneNumber = phoneNumber; - PhoneNumberConfirmed = phoneNumberConfirmed; - } - } -} \ No newline at end of file diff --git a/src/Volo.Abp.Users/Volo/Abp/Users/UserSettingValueProvider.cs b/src/Volo.Abp.Users/Volo/Abp/Users/UserSettingValueProvider.cs deleted file mode 100644 index 0a0c08bd99..0000000000 --- a/src/Volo.Abp.Users/Volo/Abp/Users/UserSettingValueProvider.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Settings; - -namespace Volo.Abp.Users -{ - //TODO: Optimization: Get all settings and cache it! - - public class UserSettingValueProvider : SettingValueProvider - { - public const string ProviderName = "User"; - - public override string Name => ProviderName; - - protected ICurrentUser CurrentUser { get; } - - public UserSettingValueProvider(ISettingStore settingStore, ICurrentUser currentUser) - : base(settingStore) - { - CurrentUser = currentUser; - } - - public override async Task GetOrNullAsync(SettingDefinition setting, string providerKey) - { - if (providerKey == null) - { - if (CurrentUser.Id == null) - { - return null; - } - - providerKey = CurrentUser.Id.ToString(); - } - - return await SettingStore.GetOrNullAsync(setting.Name, Name, providerKey); - } - - public override Task SetAsync(SettingDefinition setting, string value, string providerKey) - { - return SettingStore.SetAsync(setting.Name, value, Name, providerKey); - } - - public override Task ClearAsync(SettingDefinition setting, string providerKey) - { - return SettingStore.DeleteAsync(setting.Name, Name, providerKey); - } - } -} \ No newline at end of file