mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-09 17:48:20 +00:00
support for registration
This commit is contained in:
parent
8c2be0f37f
commit
39dc7c833d
1 changed files with 44 additions and 0 deletions
44
api/setup.go
Normal file
44
api/setup.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type SetupInstallResponse struct {
|
||||
User `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
type AuthenticationToken struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
|
||||
type SetupCompleteRequest struct {
|
||||
AuthenticationToken AuthenticationToken `json:"authenticationtoken,omitempty"`
|
||||
GPGKey GPGKey `json:"gpgkey,omitempty"`
|
||||
User User `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
// 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) {
|
||||
msg, err := c.DoCustomRequest(ctx, "GET", "/setup/install/"+userID+"/"+token+".json", "v2", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var install SetupInstallResponse
|
||||
err = json.Unmarshal(msg.Body, &install)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &install, nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Reference in a new issue