This commit is contained in:
asteam
2025-09-23 14:34:24 +03:00
parent b924e85e49
commit f1ffb4c0fd
1108 changed files with 72020 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package user
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
)
// AuthenticateRequest struct to authenticate user.
type AuthenticateRequest struct {
// Username
// Required: true
Username string `url:"username" json:"username" validate:"required"`
// Password
// Required: true
Password string `url:"password" json:"password" validate:"required"`
}
// Authenticate evaluates the provided username and password and returns a session key.
// The session key can be used for doing api requests. E.g this is the authkey parameter in every actor request.
// A session key is only vallid for a limited time.
func (u User) Authenticate(ctx context.Context, req AuthenticateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/user/authenticate"
res, err := u.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}