feat: adding password expiry

This commit is contained in:
Nelson Isioma 2025-06-23 02:46:49 +01:00
parent 5262eff022
commit 5b34b6da86
4 changed files with 20 additions and 12 deletions

View file

@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"time"
)
// Resource is a Resource.
@ -87,10 +86,6 @@ func (c *Client) GetResources(ctx context.Context, opts *GetResourcesOptions) ([
// CreateResource Creates a new Passbolt Resource
func (c *Client) CreateResource(ctx context.Context, resource Resource) (*Resource, error) {
if c.passwordExpirySettings.DefaultExpiryPeriod != 0 {
expiry := time.Now().Add(time.Hour * 24 * time.Duration(c.passwordExpirySettings.DefaultExpiryPeriod))
resource.Expired = &Time{expiry}
}
msg, err := c.DoCustomRequest(ctx, "POST", "/resources.json", "v2", resource, nil)
if err != nil {
return nil, err
@ -129,10 +124,6 @@ func (c *Client) UpdateResource(ctx context.Context, resourceID string, resource
return nil, fmt.Errorf("Checking ID format: %w", err)
}
if resource.Expired != nil && c.passwordExpirySettings.AutomaticUpdate {
expiry := time.Now().Add(time.Hour * 24 * time.Duration(c.passwordExpirySettings.DefaultExpiryPeriod))
resource.Expired = &Time{expiry}
}
msg, err := c.DoCustomRequest(ctx, "PUT", "/resources/"+resourceID+".json", "v2", resource, nil)
if err != nil {
return nil, err