mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: add additional fields to first time setup trial flow (#11533)
* feat: add additional fields to first time setup trial flow * trial generator typo
This commit is contained in:
29
coderd/apidoc/docs.go
generated
29
coderd/apidoc/docs.go
generated
@ -8261,6 +8261,9 @@ const docTemplate = `{
|
||||
"trial": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"trial_info": {
|
||||
"$ref": "#/definitions/codersdk.CreateFirstUserTrialInfo"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
@ -8279,6 +8282,32 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.CreateFirstUserTrialInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"company_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"country": {
|
||||
"type": "string"
|
||||
},
|
||||
"developers": {
|
||||
"type": "string"
|
||||
},
|
||||
"first_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"job_title": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.CreateGroupRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
29
coderd/apidoc/swagger.json
generated
29
coderd/apidoc/swagger.json
generated
@ -7353,6 +7353,9 @@
|
||||
"trial": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"trial_info": {
|
||||
"$ref": "#/definitions/codersdk.CreateFirstUserTrialInfo"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
@ -7371,6 +7374,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.CreateFirstUserTrialInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"company_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"country": {
|
||||
"type": "string"
|
||||
},
|
||||
"developers": {
|
||||
"type": "string"
|
||||
},
|
||||
"first_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"job_title": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.CreateGroupRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -123,7 +123,7 @@ type Options struct {
|
||||
TracerProvider trace.TracerProvider
|
||||
ExternalAuthConfigs []*externalauth.Config
|
||||
RealIPConfig *httpmw.RealIPConfig
|
||||
TrialGenerator func(ctx context.Context, email string) error
|
||||
TrialGenerator func(ctx context.Context, body codersdk.LicensorTrialRequest) error
|
||||
// TLSCertificates is used to mesh DERP servers securely.
|
||||
TLSCertificates []tls.Certificate
|
||||
TailnetCoordinator tailnet.Coordinator
|
||||
|
@ -107,7 +107,7 @@ type Options struct {
|
||||
Auditor audit.Auditor
|
||||
TLSCertificates []tls.Certificate
|
||||
ExternalAuthConfigs []*externalauth.Config
|
||||
TrialGenerator func(context.Context, string) error
|
||||
TrialGenerator func(ctx context.Context, body codersdk.LicensorTrialRequest) error
|
||||
TemplateScheduleStore schedule.TemplateScheduleStore
|
||||
Coordinator tailnet.Coordinator
|
||||
|
||||
|
@ -152,7 +152,16 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if createUser.Trial && api.TrialGenerator != nil {
|
||||
err = api.TrialGenerator(ctx, createUser.Email)
|
||||
err = api.TrialGenerator(ctx, codersdk.LicensorTrialRequest{
|
||||
Email: createUser.Email,
|
||||
FirstName: createUser.TrialInfo.FirstName,
|
||||
LastName: createUser.TrialInfo.LastName,
|
||||
PhoneNumber: createUser.TrialInfo.PhoneNumber,
|
||||
JobTitle: createUser.TrialInfo.JobTitle,
|
||||
CompanyName: createUser.TrialInfo.CompanyName,
|
||||
Country: createUser.TrialInfo.Country,
|
||||
Developers: createUser.TrialInfo.Developers,
|
||||
})
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Failed to generate trial",
|
||||
|
@ -76,7 +76,7 @@ func TestFirstUser(t *testing.T) {
|
||||
t.Parallel()
|
||||
called := make(chan struct{})
|
||||
client := coderdtest.New(t, &coderdtest.Options{
|
||||
TrialGenerator: func(ctx context.Context, s string) error {
|
||||
TrialGenerator: func(context.Context, codersdk.LicensorTrialRequest) error {
|
||||
close(called)
|
||||
return nil
|
||||
},
|
||||
|
Reference in New Issue
Block a user