From 9c9627dd082db2064d34d82c04786ebb18be0227 Mon Sep 17 00:00:00 2001 From: alex289 Date: Wed, 4 Sep 2024 13:03:20 +0200 Subject: [PATCH] fix: Use utc now instead of now --- CleanArchitecture.Domain/Commands/CommandBase.cs | 2 +- .../Commands/Users/LoginUser/LoginUserCommandHandler.cs | 4 ++-- CleanArchitecture.Shared/Events/DomainEvent.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CleanArchitecture.Domain/Commands/CommandBase.cs b/CleanArchitecture.Domain/Commands/CommandBase.cs index d659231..02a7f68 100644 --- a/CleanArchitecture.Domain/Commands/CommandBase.cs +++ b/CleanArchitecture.Domain/Commands/CommandBase.cs @@ -14,7 +14,7 @@ public abstract class CommandBase : IRequest protected CommandBase(Guid aggregateId) { MessageType = GetType().Name; - Timestamp = DateTime.Now; + Timestamp = DateTime.UtcNow; AggregateId = aggregateId; } diff --git a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs index c95b1e8..3e9daf8 100644 --- a/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs +++ b/CleanArchitecture.Domain/Commands/Users/LoginUser/LoginUserCommandHandler.cs @@ -70,7 +70,7 @@ public sealed class LoginUserCommandHandler : CommandHandlerBase, } user.SetActive(); - user.SetLastLoggedinDate(DateTimeOffset.Now); + user.SetLastLoggedinDate(DateTimeOffset.UtcNow); if (!await CommitAsync()) { @@ -103,7 +103,7 @@ public sealed class LoginUserCommandHandler : CommandHandlerBase, tokenSettings.Issuer, tokenSettings.Audience, claims, - expires: DateTime.Now.AddMinutes(_expiryDurationMinutes), + expires: DateTime.UtcNow.AddMinutes(_expiryDurationMinutes), signingCredentials: credentials); return new JwtSecurityTokenHandler().WriteToken(tokenDescriptor); diff --git a/CleanArchitecture.Shared/Events/DomainEvent.cs b/CleanArchitecture.Shared/Events/DomainEvent.cs index f541549..9d87903 100644 --- a/CleanArchitecture.Shared/Events/DomainEvent.cs +++ b/CleanArchitecture.Shared/Events/DomainEvent.cs @@ -9,11 +9,11 @@ public abstract class DomainEvent : Message, INotification protected DomainEvent(Guid aggregateId) : base(aggregateId) { - Timestamp = DateTime.Now; + Timestamp = DateTime.UtcNow; } protected DomainEvent(Guid aggregateId, string? messageType) : base(aggregateId, messageType) { - Timestamp = DateTime.Now; + Timestamp = DateTime.UtcNow; } } \ No newline at end of file