From 9d296b20925d3a4b7e6d0b99ab29d9e329374218 Mon Sep 17 00:00:00 2001 From: jrmccannon Date: Tue, 25 Jun 2024 10:15:01 -0500 Subject: [PATCH] Used TimeProvider --- .../Authorization/StepUpAuthorizationHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Passwordless.AspNetIdentity.Example/Authorization/StepUpAuthorizationHandler.cs b/examples/Passwordless.AspNetIdentity.Example/Authorization/StepUpAuthorizationHandler.cs index 05d1b3a..523072b 100644 --- a/examples/Passwordless.AspNetIdentity.Example/Authorization/StepUpAuthorizationHandler.cs +++ b/examples/Passwordless.AspNetIdentity.Example/Authorization/StepUpAuthorizationHandler.cs @@ -11,7 +11,7 @@ public interface IStepUpAuthorizationRequirement : IAuthorizationRequirement public string Name { get; } } -public class StepUpAuthorizationHandler(StepUpPurpose stepUpPurpose) : AuthorizationHandler +public class StepUpAuthorizationHandler(StepUpPurpose stepUpPurpose, TimeProvider timeProvider) : AuthorizationHandler { protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, IStepUpAuthorizationRequirement requirement) { @@ -36,9 +36,9 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte private static Predicate MatchesClaim(IStepUpAuthorizationRequirement requirement) => claim => claim.Type == requirement.Name; - private static bool IsExpired(DateTime expiration) + private bool IsExpired(DateTime expiration) { - return expiration > DateTime.UtcNow; + return expiration > timeProvider.GetUtcNow().DateTime; } private static DateTime GetExpiration(Claim claim)