mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
663-AccessTokens validate expiration date (#3104)
* 663-AccessTokens validate expiration date * removing unecessary using statement * thomas' suggested change * Thomas' suggested change * Update src/Api/SecretsManager/Models/Request/AccessTokenCreateRequestModel.cs Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> --------- Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
This commit is contained in:
parent
222d57622e
commit
174d890234
@ -4,7 +4,7 @@ using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.SecretsManager.Models.Request;
|
||||
|
||||
public class AccessTokenCreateRequestModel
|
||||
public class AccessTokenCreateRequestModel : IValidatableObject
|
||||
{
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
@ -34,4 +34,13 @@ public class AccessTokenCreateRequestModel
|
||||
EncryptedPayload = EncryptedPayload,
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (ExpireAt != null && ExpireAt <= DateTime.UtcNow)
|
||||
{
|
||||
yield return new ValidationResult(
|
||||
$"Please select an expiration date that is in the future.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user