From d4541183116d0989708d790351d4e72c6337002a Mon Sep 17 00:00:00 2001 From: Gianmarco Manni Date: Tue, 5 Aug 2025 08:48:36 +0200 Subject: [PATCH 1/3] x --- CHANGELOG.md | 4 ++++ .../ITokenSignInManager.cs | 8 +++++++ .../TokenSignManager.cs | 22 ++++++++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4d5f3..32ad54a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- a new overload for method `PasswordSignInAsync` of `ITokenSignInManager` which accepts TUser entity parameter + ## [0.5.0] - 2025-02-11 ### Added diff --git a/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs b/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs index 29e2659..5a38b9a 100644 --- a/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs +++ b/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs @@ -10,6 +10,14 @@ public interface ITokenSignInManager where TUser : IdentityUser { + /// + /// Passwords the sign in asynchronous. + /// + /// The user. + /// The password. + /// The JWT if signed in; otherwise null. + Task PasswordSignInAsync(TUser user, string password); + /// /// Sign-in with a password. /// diff --git a/Neolution.Extensions.Identity/TokenSignManager.cs b/Neolution.Extensions.Identity/TokenSignManager.cs index ea43a3f..374b3cd 100644 --- a/Neolution.Extensions.Identity/TokenSignManager.cs +++ b/Neolution.Extensions.Identity/TokenSignManager.cs @@ -49,6 +49,19 @@ public TokenSignManager(ILogger> logger, IUserManager + public async Task PasswordSignInAsync(TUser user, string password) + { + var signInResponse = await this.signInManager.CheckPasswordSignInAsync(user, password, true); + if (signInResponse.Succeeded) + { + return await this.CreateAccessTokenAsync(user, "pwd", "identity-store"); + } + + this.logger.LogWarning("Password sign-in for user email={Email}/username={Username} failed", user.Email, user.UserName); + return null; + } + /// public async Task PasswordSignInAsync(string email, string password) { @@ -59,14 +72,7 @@ public TokenSignManager(ILogger> logger, IUserManager From d98277040821321198bc2b0b22dd6fba3a69ff34 Mon Sep 17 00:00:00 2001 From: "Sandro C." Date: Tue, 5 Aug 2025 09:11:56 +0200 Subject: [PATCH 2/3] Update Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ITokenSignInManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs b/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs index 5a38b9a..6c513bb 100644 --- a/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs +++ b/Neolution.Extensions.Identity.Abstractions/ITokenSignInManager.cs @@ -11,7 +11,7 @@ public interface ITokenSignInManager where TUser : IdentityUser { /// - /// Passwords the sign in asynchronous. + /// Signs in a user with their password asynchronously. /// /// The user. /// The password. From d7c93a5ac90bd959167046aa1728f919a8cbf11e Mon Sep 17 00:00:00 2001 From: Gianmarco Manni Date: Tue, 5 Aug 2025 09:52:51 +0200 Subject: [PATCH 3/3] x --- Neolution.Extensions.Identity/TokenSignManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Neolution.Extensions.Identity/TokenSignManager.cs b/Neolution.Extensions.Identity/TokenSignManager.cs index 374b3cd..f4195e9 100644 --- a/Neolution.Extensions.Identity/TokenSignManager.cs +++ b/Neolution.Extensions.Identity/TokenSignManager.cs @@ -52,6 +52,7 @@ public TokenSignManager(ILogger> logger, IUserManager public async Task PasswordSignInAsync(TUser user, string password) { + this.logger.LogTrace("Perform password sign-in for user email={Email}/username={Username}", user.Email, user.UserName); var signInResponse = await this.signInManager.CheckPasswordSignInAsync(user, password, true); if (signInResponse.Succeeded) {