| | | 1 | | namespace ArturRios.Heimdall.Command.Services; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Settings for email-verification token issuance. <see cref="TokenLifetime" /> is read from the |
| | | 5 | | /// environment (seconds) with a 24-hour default. |
| | | 6 | | /// </summary> |
| | | 7 | | public class EmailVerificationOptions |
| | | 8 | | { |
| | | 9 | | private const string LifetimeVariable = "HEIMDALL_EMAIL_VERIFICATION_TOKEN_EXPIRATION_IN_SECONDS"; |
| | | 10 | | private const double DefaultLifetimeSeconds = 86400; |
| | | 11 | | |
| | 1942 | 12 | | public TimeSpan TokenLifetime { get; init; } = TimeSpan.FromSeconds(DefaultLifetimeSeconds); |
| | | 13 | | |
| | | 14 | | public static EmailVerificationOptions FromEnvironment() |
| | | 15 | | { |
| | 899 | 16 | | var seconds = double.TryParse(Environment.GetEnvironmentVariable(LifetimeVariable), out var configured) |
| | 899 | 17 | | ? configured |
| | 899 | 18 | | : DefaultLifetimeSeconds; |
| | | 19 | | |
| | 899 | 20 | | return new EmailVerificationOptions { TokenLifetime = TimeSpan.FromSeconds(seconds) }; |
| | | 21 | | } |
| | | 22 | | } |