From c232b8d761136c8efc6bac893ac57455934e72d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 6 Aug 2020 14:18:32 +0300 Subject: [PATCH] Create and register AbpSignInManager. --- .../AspNetCore/AbpIdentityAspNetCoreModule.cs | 5 ++- .../Identity/AspNetCore/AbpSignInManager.cs | 41 +++++++++++++++++++ .../AspNetCore/AbpSignInManager_Tests.cs | 9 ++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs index c0e3031568..019ef0469e 100644 --- a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs @@ -13,8 +13,9 @@ namespace Volo.Abp.Identity.AspNetCore { PreConfigure(builder => { - builder.AddDefaultTokenProviders(); - builder.AddSignInManager(); + builder + .AddDefaultTokenProviders() + .AddSignInManager(); }); } diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs new file mode 100644 index 0000000000..30f9407e6e --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSignInManager.cs @@ -0,0 +1,41 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Volo.Abp.Identity.AspNetCore +{ + public class AbpSignInManager : SignInManager + { + public AbpSignInManager( + UserManager userManager, + IHttpContextAccessor contextAccessor, + IUserClaimsPrincipalFactory claimsFactory, + IOptions optionsAccessor, + ILogger> logger, + IAuthenticationSchemeProvider schemes, + IUserConfirmation confirmation + ) : base( + userManager, + contextAccessor, + claimsFactory, + optionsAccessor, + logger, + schemes, + confirmation) + { + + } + + public override Task PasswordSignInAsync( + string userName, + string password, + bool isPersistent, + bool lockoutOnFailure) + { + return base.PasswordSignInAsync(userName, password, isPersistent, lockoutOnFailure); + } + } +} diff --git a/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpSignInManager_Tests.cs b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpSignInManager_Tests.cs index 268bfae40c..212c341733 100644 --- a/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpSignInManager_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.AspNetCore.Tests/Volo/Abp/Identity/AspNetCore/AbpSignInManager_Tests.cs @@ -1,6 +1,7 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.AspNetCore.Identity; using Shouldly; using Xunit; @@ -8,6 +9,13 @@ namespace Volo.Abp.Identity.AspNetCore { public class AbpSignInManager_Tests : AbpIdentityAspNetCoreTestBase { + [Fact] + public async Task Should_Resolve_AbpSignInManager() + { + var signInManager = GetRequiredService>(); + signInManager.ShouldBeOfType(); + } + [Fact] public async Task Should_SignIn_With_Correct_Credentials() { @@ -17,6 +25,7 @@ namespace Volo.Abp.Identity.AspNetCore result.ShouldBe("Succeeded"); } + [Fact] public async Task Should_Not_SignIn_With_Wrong_Credentials() {