From ca33be9533c9c50732dd59038c9678530813bcdf Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=B3=A8=E5=86=8C=E9=AA=8C=E8=AF=81;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LINGYUN/Abp/Account/AccountAppService.cs | 20 ++++++-- .../Abp/Account/AbpAccountDomainModule.cs | 3 +- .../Abp/Account/IIdentityUserRepository.cs | 2 + .../Account/Localization/Resources/en.json | 5 +- .../Localization/Resources/zh-Hans.json | 5 +- .../Identity/PhoneNumberUserValidator.cs | 48 +++++++++++++++++++ .../LINGYUN.Abp.DistributedLock.csproj | 7 +++ .../LINGYUN.Abp.IM.SignalR.csproj | 6 +++ .../LINGYUN/Abp/IM/SignalR/Hubs/MessageHub.cs | 6 +++ .../LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj | 8 +++- ...INGYUN.Abp.Identity.OverrideOptions.csproj | 6 +++ .../LINGYUN.Abp.Notifications.SignalR.csproj | 6 +++ .../LINGYUN.Abp.Notifications.csproj | 7 +++ .../LINGYUN.Abp.RealTime.csproj | 6 +++ .../LINGYUN.Abp.RedisLock.csproj | 6 +++ .../UserCreateSendWelcomeEventHandler.cs | 33 +++++++------ .../EfCoreIdentityUserExtensionRepository.cs | 7 ++- aspnet-core/services/cleanup-logs.bat | 7 ++- .../EfCoreIdentityUserExtensionRepository.cs | 7 ++- .../PlatformHttpApiHostMigrationsDbContext.cs | 35 ++++++++++++++ ...rmHttpApiHostMigrationsDbContextFactory.cs | 29 +++++++++++ ...enantConnectionStringCreateEventHandler.cs | 11 +++++ .../Handlers/TenantCreateEventHandler.cs | 2 +- .../Handlers/TenantDeleteEventHandler.cs | 2 +- 24 files changed, 246 insertions(+), 28 deletions(-) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/Microsoft/AspNetCore/Identity/PhoneNumberUserValidator.cs create mode 100644 aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs create mode 100644 aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs create mode 100644 aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs index 0ec05b642..2c8412887 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs @@ -18,18 +18,21 @@ namespace LINGYUN.Abp.Account { protected ISmsSender SmsSender { get; } protected IdentityUserManager UserManager { get; } + protected IdentityUserStore UserStore { get; } protected IIdentityUserRepository UserRepository { get; } protected IDistributedCache Cache { get; } protected PhoneNumberTokenProvider PhoneNumberTokenProvider { get; } public AccountAppService( ISmsSender smsSender, IdentityUserManager userManager, + IdentityUserStore userStore, IIdentityUserRepository userRepository, IDistributedCache cache, PhoneNumberTokenProvider phoneNumberTokenProvider) { Cache = cache; SmsSender = smsSender; + UserStore = userStore; UserManager = userManager; UserRepository = userRepository; PhoneNumberTokenProvider = phoneNumberTokenProvider; @@ -57,16 +60,27 @@ namespace LINGYUN.Abp.Account await CheckSelfRegistrationAsync(); - var userEmail = input.EmailAddress ?? input.PhoneNumber + "@abp.io"; + // 需要用户输入邮箱? + //if (UserManager.Options.User.RequireUniqueEmail) + //{ + // if (input.EmailAddress.IsNullOrWhiteSpace()) + // { + // throw new UserFriendlyException(L["RequiredEmailAddress"]); + // } + //} + + var userEmail = input.EmailAddress ?? $"{input.PhoneNumber}@{new Random().Next(1000, 99999)}.com";//如果邮件地址不验证,随意写入一个 var userName = input.UserName ?? input.PhoneNumber; var user = new IdentityUser(GuidGenerator.Create(), userName, userEmail, CurrentTenant.Id) { Name = input.Name ?? input.PhoneNumber }; + // 写入手机号要在创建用户之前,因为有一个自定义的手机号验证 + await UserStore.SetPhoneNumberAsync(user, input.PhoneNumber); + await UserStore.SetPhoneNumberConfirmedAsync(user, true); + (await UserManager.CreateAsync(user, input.Password)).CheckErrors(); - (await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); - (await UserManager.SetEmailAsync(user, userEmail)).CheckErrors(); (await UserManager.AddDefaultRolesAsync(user)).CheckErrors(); await Cache.RemoveAsync(phoneVerifyCacheKey); diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs index 0ad58c817..38693428c 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Localization; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs index 54817fc92..16fd24b24 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs @@ -7,6 +7,8 @@ namespace LINGYUN.Abp.Account { public interface IIdentityUserRepository : IReadOnlyRepository { + Task PhoneNumberHasRegistedAsync(string phoneNumber); + Task FindByPhoneNumberAsync(string phoneNumber); } } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json index 488ddc52f..011e17b0d 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/en.json @@ -9,6 +9,9 @@ "DisplayName:SmsSigninTemplateCode": "Signin sms template", "Description:SmsSigninTemplateCode": "When the user logs in, he/she should send the template number of the SMS verification code and fill in the template number of the corresponding cloud platform registration", "DisplayName:PhoneVerifyCodeExpiration": "SMS verification code validity", - "Description:PhoneVerifyCodeExpiration": "The valid time for the user to send SMS verification code, unit m, default 3m" + "Description:PhoneVerifyCodeExpiration": "The valid time for the user to send SMS verification code, unit m, default 3m", + "RequiredEmailAddress": "Email address required", + "InvalidPhoneNumber": "Invalid phone number", + "DuplicatePhoneNumber": "The phone number {0} has been registered!" } } \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json index 479cf69fa..153fc9e6f 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json @@ -9,6 +9,9 @@ "DisplayName:SmsSigninTemplateCode": "用户登录短信模板", "Description:SmsSigninTemplateCode": "用户登录时发送短信验证码的模板号,填写对应云平台注册的模板号", "DisplayName:PhoneVerifyCodeExpiration": "短信验证码有效期", - "Description:PhoneVerifyCodeExpiration": "用户发送短信验证码的有效时长,单位m,默认3m" + "Description:PhoneVerifyCodeExpiration": "用户发送短信验证码的有效时长,单位m,默认3m", + "RequiredEmailAddress": "邮件地址必须输入", + "InvalidPhoneNumber": "手机号无效", + "DuplicatePhoneNumber": "手机号已经注册过!" } } \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/Microsoft/AspNetCore/Identity/PhoneNumberUserValidator.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/Microsoft/AspNetCore/Identity/PhoneNumberUserValidator.cs new file mode 100644 index 000000000..861de3343 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/Microsoft/AspNetCore/Identity/PhoneNumberUserValidator.cs @@ -0,0 +1,48 @@ +using LINGYUN.Abp.Account.Localization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Identity; +using IIdentityUserRepository = LINGYUN.Abp.Account.IIdentityUserRepository; + +namespace Microsoft.AspNetCore.Identity +{ + [Dependency(ServiceLifetime.Scoped, ReplaceServices = true)] + [ExposeServices(typeof(IUserValidator))] + public class PhoneNumberUserValidator : UserValidator + { + private readonly IStringLocalizer _stringLocalizer; + private readonly IIdentityUserRepository _identityUserRepository; + + public PhoneNumberUserValidator( + IStringLocalizer stringLocalizer, + IIdentityUserRepository identityUserRepository) + { + _stringLocalizer = stringLocalizer; + _identityUserRepository = identityUserRepository; + } + public override async Task ValidateAsync(UserManager manager, IdentityUser user) + { + await ValidatePhoneNumberAsync(manager, user); + return await base.ValidateAsync(manager, user); + } + + protected virtual async Task ValidatePhoneNumberAsync(UserManager manager, IdentityUser user) + { + var phoneNumber = await manager.GetPhoneNumberAsync(user); + if (phoneNumber.IsNullOrWhiteSpace()) + { + throw new UserFriendlyException(_stringLocalizer["InvalidPhoneNumber"].Value, "InvalidPhoneNumber"); + } + + var phoneNumberHasRegisted = await _identityUserRepository.PhoneNumberHasRegistedAsync(phoneNumber); + if (phoneNumberHasRegisted) + { + throw new UserFriendlyException(_stringLocalizer["DuplicatePhoneNumber", phoneNumber].Value, "DuplicatePhoneNumber"); + } + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock/LINGYUN.Abp.DistributedLock.csproj b/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock/LINGYUN.Abp.DistributedLock.csproj index 9115b80b6..fde3b4b65 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock/LINGYUN.Abp.DistributedLock.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock/LINGYUN.Abp.DistributedLock.csproj @@ -3,6 +3,13 @@ netstandard2.0 + false + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj index 7718a5418..3247899f8 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj @@ -3,6 +3,12 @@ netcoreapp3.1 + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessageHub.cs b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessageHub.cs index 75b05f35e..cf47eeaa5 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessageHub.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN/Abp/IM/SignalR/Hubs/MessageHub.cs @@ -65,6 +65,12 @@ namespace LINGYUN.Abp.IM.SignalR.Hubs { var onlineClientContext = new OnlineClientContext(chatMessage.TenantId, chatMessage.ToUserId.GetValueOrDefault()); var onlineClients = OnlineClientManager.GetAllByContext(onlineClientContext); + + // 需要捕捉每一个发送任务的异常吗? + // var onlineClientConnections = onlineClients.Select(c => c.ConnectionId).ToImmutableList(); + // var signalRClient = Clients.Clients(onlineClientConnections); + // await signalRClient.SendAsync("getChatMessage", chatMessage); + foreach (var onlineClient in onlineClients) { try diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj index db4635ca9..6816a06e0 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj @@ -1,8 +1,14 @@ - + netstandard2.0 + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj index 5260b1752..7aa706913 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Identity.OverrideOptions/LINGYUN.Abp.Identity.OverrideOptions.csproj @@ -3,6 +3,12 @@ netstandard2.0 + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj index 1d4d15feb..6064b8b2e 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj @@ -3,6 +3,12 @@ netcoreapp3.1 + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj index 60d5efeb9..cacc267e4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj @@ -3,6 +3,13 @@ netstandard2.0 + false + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj b/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj index 268dae169..40c98d45b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj @@ -3,6 +3,12 @@ netstandard2.0 + 2.8.0 + true + + + + D:\LocalNuget diff --git a/aspnet-core/modules/common/LINGYUN.Abp.RedisLock/LINGYUN.Abp.RedisLock.csproj b/aspnet-core/modules/common/LINGYUN.Abp.RedisLock/LINGYUN.Abp.RedisLock.csproj index b9df59cc8..f615b282b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.RedisLock/LINGYUN.Abp.RedisLock.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.RedisLock/LINGYUN.Abp.RedisLock.csproj @@ -3,6 +3,12 @@ netstandard2.0 + true + 2.8.0 + + + + D:\LocalNuget diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserCreateSendWelcomeEventHandler.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserCreateSendWelcomeEventHandler.cs index 6bea621c6..0b2cb061e 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserCreateSendWelcomeEventHandler.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/EventBus/Local/UserCreateSendWelcomeEventHandler.cs @@ -44,26 +44,29 @@ namespace LINGYUN.Abp.MessageService.EventBus { // 获取默认语言 var userDefaultCultureName = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); - if (!userDefaultCultureName.IsNullOrWhiteSpace()) + if (userDefaultCultureName.IsNullOrWhiteSpace()) { - CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(userDefaultCultureName); + userDefaultCultureName = CultureInfo.CurrentUICulture.Name; // CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(userDefaultCultureName); } - // 订阅用户欢迎消息 - await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId, - eventData.Entity.Id, UserNotificationNames.WelcomeToApplication); - - var userWelcomeNotifiction = new NotificationInfo + using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName)) { - CreationTime = DateTime.Now, - Name = UserNotificationNames.WelcomeToApplication, - NotificationSeverity = NotificationSeverity.Info, - NotificationType = NotificationType.System, - TenantId = eventData.Entity.TenantId - }; - userWelcomeNotifiction.Data.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.UserName); + // 订阅用户欢迎消息 + await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId, + eventData.Entity.Id, UserNotificationNames.WelcomeToApplication); + + var userWelcomeNotifiction = new NotificationInfo + { + CreationTime = DateTime.Now, + Name = UserNotificationNames.WelcomeToApplication, + NotificationSeverity = NotificationSeverity.Info, + NotificationType = NotificationType.System, + TenantId = eventData.Entity.TenantId + }; + userWelcomeNotifiction.Data.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.UserName); - await _notificationDispatcher.DispatcheAsync(userWelcomeNotifiction); + await _notificationDispatcher.DispatcheAsync(userWelcomeNotifiction); + } } //public async Task HandleEventAsync(EntityCreatedEventData eventData) diff --git a/aspnet-core/services/account/AuthServer.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs b/aspnet-core/services/account/AuthServer.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs index 62593211a..22163ee4e 100644 --- a/aspnet-core/services/account/AuthServer.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs +++ b/aspnet-core/services/account/AuthServer.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs @@ -19,7 +19,12 @@ namespace AuthServer.Host.EntityFrameworkCore.Identity { } - public async Task FindByPhoneNumberAsync(string phoneNumber) + public virtual async Task PhoneNumberHasRegistedAsync(string phoneNumber) + { + return await DbSet.AnyAsync(x => x.PhoneNumberConfirmed && x.PhoneNumber.Equals(phoneNumber)); + } + + public virtual async Task FindByPhoneNumberAsync(string phoneNumber) { return await WithDetails() .Where(usr => usr.PhoneNumber.Equals(phoneNumber)) diff --git a/aspnet-core/services/cleanup-logs.bat b/aspnet-core/services/cleanup-logs.bat index 56d1f3d39..6375621d7 100644 --- a/aspnet-core/services/cleanup-logs.bat +++ b/aspnet-core/services/cleanup-logs.bat @@ -2,7 +2,10 @@ cls chcp 65001 -echo. 启动平台管理服务 +echo. 清理所有服务日志 -cd .\platform\LINGYUN.Platform.HttpApi.Host +del .\platform\LINGYUN.Platform.HttpApi.Host\Logs /y +del .\apigateway\LINGYUN.ApiGateway.Host\Logs /y +del .\apigateway\LINGYUN.ApiGateway.HttpApi.Host\Logs /y +del .\account\AuthServer.Host\Logs /y diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs index 7809d6795..f1e2a7121 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/Identity/EfCoreIdentityUserExtensionRepository.cs @@ -19,7 +19,12 @@ namespace LINGYUN.Platform.EntityFrameworkCore.Identity { } - public async Task FindByPhoneNumberAsync(string phoneNumber) + public virtual async Task PhoneNumberHasRegistedAsync(string phoneNumber) + { + return await DbSet.AnyAsync(x => x.PhoneNumberConfirmed && x.PhoneNumber.Equals(phoneNumber)); + } + + public virtual async Task FindByPhoneNumberAsync(string phoneNumber) { return await DbSet.Where(usr => usr.PhoneNumber.Equals(phoneNumber)).FirstOrDefaultAsync(); } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs new file mode 100644 index 000000000..8c7382a55 --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContext.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.IdentityServer.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; +using Volo.Abp.TenantManagement.EntityFrameworkCore; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public class PlatformHttpApiHostMigrationsDbContext : AbpDbContext + { + public PlatformHttpApiHostMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.ConfigureIdentity(); + modelBuilder.ConfigureIdentityServer(options => + { + options.TablePrefix = "IdentityServer"; + options.Schema = null; + options.DatabaseProvider = EfCoreDatabaseProvider.MySql; + }); + modelBuilder.ConfigureTenantManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigurePermissionManagement(); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs new file mode 100644 index 000000000..9dd641cfd --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EntityFrameworkCore/PlatformHttpApiHostMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public class PlatformHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory + { + public PlatformHttpApiHostMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseMySql(configuration.GetConnectionString("Default")); + + return new PlatformHttpApiHostMigrationsDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.Development.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs new file mode 100644 index 000000000..6b70ba77a --- /dev/null +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantConnectionStringCreateEventHandler.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace LINGYUN.Platform.EventBus.Handlers +{ + public class TenantConnectionStringCreateEventHandler + { + } +} diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs index 52467ef6f..2eb2c586d 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs @@ -70,7 +70,7 @@ namespace LINGYUN.Platform.EventBus.Handlers } await PermissionGrantRepository.GetDbContext().Database.ExecuteSqlRawAsync(batchInsertPermissionSql); - await unitOfWork.CompleteAsync(); + await unitOfWork.SaveChangesAsync(); } } } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs index aae3df09a..d642b1eea 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs @@ -57,7 +57,7 @@ namespace LINGYUN.Platform.EventBus.Handlers await PermissionGrantRepository.GetDbContext().Database .ExecuteSqlRawAsync(batchRmovePermissionSql); - await unitOfWork.CompleteAsync(); + await unitOfWork.SaveChangesAsync(); } }