Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public TwoFactorRememberTokenable CreateToken(User user, Device device, string s
{
ExpirationDate = timeProvider.GetUtcNow().UtcDateTime
.AddDays(globalSettings.TwoFactorRememberTokenLifetimeInDays),
TimeProvider = timeProvider,
};
}
8 changes: 7 additions & 1 deletion src/Core/Tokens/ExpiringTokenable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public abstract class ExpiringTokenable : Tokenable
/// </summary>
public override bool Valid => !IsExpired && TokenIsValid();

public bool IsExpired => ExpirationDate < DateTime.UtcNow;
/// <summary>
/// Clock used for the expiration check. Can be overwritten for tests.
/// </summary>
[JsonIgnore]
internal TimeProvider TimeProvider { get; set; } = TimeProvider.System;

public bool IsExpired => ExpirationDate < TimeProvider.GetUtcNow().UtcDateTime;

/// <summary>
/// Validates that the token data properties are correct.
Expand Down
Loading