diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs index 40847b7ba8..9946ac5b37 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpUserClaimsPrincipalFactory.cs @@ -5,31 +5,22 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; -using Volo.Abp.MultiTenancy; using Volo.Abp.Security.Claims; using Volo.Abp.Uow; -using Volo.Abp.Users; namespace Volo.Abp.Identity { public class AbpUserClaimsPrincipalFactory : UserClaimsPrincipalFactory, ITransientDependency { - protected ICurrentUser CurrentUser { get; } - protected ICurrentTenant CurrentTenant { get; } - public AbpUserClaimsPrincipalFactory( UserManager userManager, RoleManager roleManager, - IOptions options, - ICurrentUser currentUser, - ICurrentTenant currentTenant) + IOptions options) : base( userManager, roleManager, options) { - CurrentUser = currentUser; - CurrentTenant = currentTenant; } [UnitOfWork] diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/en.json b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/en.json index f974297b06..f582705ce4 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/en.json +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/en.json @@ -1,4 +1,4 @@ -{ +{ "culture": "en", "texts": { "Volo.IdentityServer:DuplicateIdentityResourceName": "Identity Resource name already exist: {Name}", @@ -7,6 +7,7 @@ "UserLockedOut": "The user account has been locked out due to invalid login attempts. Please wait a while and try again.", "InvalidUserNameOrPassword": "Invalid username or password!", "LoginIsNotAllowed": "You are not allowed to login! You need to confirm your email/phone number.", - "InvalidUsername": "Invalid username or password!" + "InvalidUsername": "Invalid username or password!", + "TheTargetUserIsNotLinkedToYou": "The target user is not linked to you!" } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/tr.json b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/tr.json index 60f7a75a77..8a90e54172 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/tr.json +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/tr.json @@ -7,6 +7,7 @@ "UserLockedOut": "Kullanıcı hesabı hatalı giriş denemeleri nedeniyle kilitlenmiştir. Lütfen bir süre bekleyip tekrar deneyin.", "InvalidUserNameOrPassword": "Kullanıcı adı ya da şifre geçersiz!", "LoginIsNotAllowed": "Giriş yapamazsınız! E-posta adresinizi ya da telefon numaranızı doğrulamanız gerekiyor.", - "InvalidUsername": "Kullanıcı adı ya da şifre geçersiz!" + "InvalidUsername": "Kullanıcı adı ya da şifre geçersiz!", + "TheTargetUserIsNotLinkedToYou": "Hedef kullanıcı sizinle bağlantılı değil!" } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/zh-Hans.json b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/zh-Hans.json index ac175e574d..ebe694ec7c 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/zh-Hans.json +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Localization/Resources/zh-Hans.json @@ -7,6 +7,7 @@ "UserLockedOut": "登录失败,用户账户已被锁定.请稍后再试.", "InvalidUserNameOrPassword": "用户名或密码错误!", "LoginIsNotAllowed": "无法登录!你需要验证邮箱地址/手机号.", - "InvalidUsername": "用户名或密码错误!" + "InvalidUsername": "用户名或密码错误!", + "TheTargetUserIsNotLinkedToYou": "目标用户未和你有关联!" } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/LinkLoginExtensionGrantValidator.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/LinkLoginExtensionGrantValidator.cs index 3f4ff7dcf2..cc74afa175 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/LinkLoginExtensionGrantValidator.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/LinkLoginExtensionGrantValidator.cs @@ -17,7 +17,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity { public class LinkLoginExtensionGrantValidator : IExtensionGrantValidator { - public const string ExtensionGrantType = "LinkUserLogin"; + public const string ExtensionGrantType = "LinkLogin"; public string GrantType => ExtensionGrantType; @@ -80,8 +80,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity using (CurrentPrincipalAccessor.Change(result.Claims)) { - var linkUserId = Guid.Empty;; - if (!StringToGuid(context.Request.Raw["LinkUserId"], ref linkUserId)) + if (!Guid.TryParse(context.Request.Raw["LinkUserId"], out var linkUserId)) { context.Result = new GrantValidationResult { @@ -94,7 +93,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity Guid? linkTenantId = null; if (!context.Request.Raw["LinkTenantId"].IsNullOrWhiteSpace()) { - if (!StringToGuid(context.Request.Raw["LinkTenantId"], ref linkTenantId)) + if (!Guid.TryParse(context.Request.Raw["LinkUserId"], out var parsedGuid)) { context.Result = new GrantValidationResult { @@ -103,6 +102,8 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity }; return; } + + linkTenantId = parsedGuid; } var isLinked = await IdentityLinkUserManager.IsLinkedAsync( @@ -131,8 +132,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity context.Result = new GrantValidationResult { IsError = true, - //TODO: Localizer error message. - Error = "The_Target_User_Is_Not_Linked_ToYou" + Error = Localizer["TheTargetUserIsNotLinkedToYou"] }; } } @@ -147,33 +147,5 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity return Task.CompletedTask; } - - protected virtual bool StringToGuid(string str, ref Guid guid) - { - if (str.IsNullOrWhiteSpace()) - { - return false; - } - - if (Guid.TryParse(str, out var g)) - { - guid = g; - return true; - } - - return false; - } - - protected virtual bool StringToGuid(string str, ref Guid? guid) - { - var g = Guid.Empty; - if (StringToGuid(str, ref g)) - { - guid = g; - return true; - } - - return false; - } } }