mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
feat: adding password expiry
This commit is contained in:
parent
5262eff022
commit
5b34b6da86
4 changed files with 20 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue