mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-09-13 14:29:09 +00:00
add uuid check before insering into url
This commit is contained in:
parent
f3fe6eb1c5
commit
f1122a019c
13 changed files with 162 additions and 12 deletions
15
api/setup.go
15
api/setup.go
|
@ -3,6 +3,7 @@ package api
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type SetupInstallResponse struct {
|
||||
|
@ -21,6 +22,14 @@ type SetupCompleteRequest struct {
|
|||
|
||||
// SetupInstall validates the userid and token used for Account setup, gives back the User Information
|
||||
func (c *Client) SetupInstall(ctx context.Context, userID, token string) (*SetupInstallResponse, error) {
|
||||
err := checkUUIDFormat(userID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Checking ID format: %w", err)
|
||||
}
|
||||
err = checkUUIDFormat(token)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Checking Token format: %w", err)
|
||||
}
|
||||
msg, err := c.DoCustomRequest(ctx, "GET", "/setup/install/"+userID+"/"+token+".json", "v2", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -36,7 +45,11 @@ func (c *Client) SetupInstall(ctx context.Context, userID, token string) (*Setup
|
|||
|
||||
// SetupComplete Completes setup of a Passbolt Account
|
||||
func (c *Client) SetupComplete(ctx context.Context, userID string, request SetupCompleteRequest) error {
|
||||
_, err := c.DoCustomRequest(ctx, "POST", "/setup/complete/"+userID+".json", "v2", request, nil)
|
||||
err := checkUUIDFormat(userID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Checking ID format: %w", err)
|
||||
}
|
||||
_, err = c.DoCustomRequest(ctx, "POST", "/setup/complete/"+userID+".json", "v2", request, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue