From 888c43a5077bb46e640795205d1ee541cf48822c Mon Sep 17 00:00:00 2001 From: Geoffrey Huntley Date: Sun, 23 Oct 2022 16:10:27 +0000 Subject: [PATCH 1/2] feat(setup): organization is not longer needed --- cli/login.go | 7 +++---- cli/resetpassword_test.go | 7 +++---- cli/server_test.go | 7 +++---- coderd/coderdtest/coderdtest.go | 7 +++---- coderd/users_test.go | 14 ++++++-------- codersdk/users.go | 7 +++---- site/src/api/typesGenerated.ts | 1 - site/src/pages/SetupPage/SetupPage.test.tsx | 6 ------ site/src/pages/SetupPage/SetupPageView.tsx | 12 ------------ 9 files changed, 21 insertions(+), 47 deletions(-) diff --git a/cli/login.go b/cli/login.go index 7c9fd04550189..e31f29fb34697 100644 --- a/cli/login.go +++ b/cli/login.go @@ -163,10 +163,9 @@ func login() *cobra.Command { } _, err = client.CreateFirstUser(cmd.Context(), codersdk.CreateFirstUserRequest{ - Email: email, - Username: username, - OrganizationName: username, - Password: password, + Email: email, + Username: username, + Password: password, }) if err != nil { return xerrors.Errorf("create initial user: %w", err) diff --git a/cli/resetpassword_test.go b/cli/resetpassword_test.go index 508a9304d8ef3..02d4855eb02f0 100644 --- a/cli/resetpassword_test.go +++ b/cli/resetpassword_test.go @@ -60,10 +60,9 @@ func TestResetPassword(t *testing.T) { client := codersdk.New(accessURL) _, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{ - Email: email, - Username: username, - Password: oldPassword, - OrganizationName: "example", + Email: email, + Username: username, + Password: oldPassword, }) require.NoError(t, err) diff --git a/cli/server_test.go b/cli/server_test.go index 615bebbf9a7f3..c59a0afa52213 100644 --- a/cli/server_test.go +++ b/cli/server_test.go @@ -71,10 +71,9 @@ func TestServer(t *testing.T) { client := codersdk.New(accessURL) _, err = client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{ - Email: "some@one.com", - Username: "example", - Password: "password", - OrganizationName: "example", + Email: "some@one.com", + Username: "example", + Password: "password", }) require.NoError(t, err) cancelFunc() diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index e57e396fde0e0..0452042c36ae7 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -346,10 +346,9 @@ func NewProvisionerDaemon(t *testing.T, coderAPI *coderd.API) io.Closer { } var FirstUserParams = codersdk.CreateFirstUserRequest{ - Email: "testuser@coder.com", - Username: "testuser", - Password: "testpass", - OrganizationName: "testorg", + Email: "testuser@coder.com", + Username: "testuser", + Password: "testpass", } // CreateFirstUser creates a user with preset credentials and authenticates diff --git a/coderd/users_test.go b/coderd/users_test.go index c16181562d567..951c455206195 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -49,10 +49,9 @@ func TestFirstUser(t *testing.T) { defer cancel() _, err := client.CreateFirstUser(ctx, codersdk.CreateFirstUserRequest{ - Email: "some@email.com", - Username: "exampleuser", - Password: "password", - OrganizationName: "someorg", + Email: "some@email.com", + Username: "exampleuser", + Password: "password", }) var apiErr *codersdk.Error require.ErrorAs(t, err, &apiErr) @@ -249,10 +248,9 @@ func TestPostLogin(t *testing.T) { defer cancel() req := codersdk.CreateFirstUserRequest{ - Email: "testuser@coder.com", - Username: "testuser", - Password: "testpass", - OrganizationName: "testorg", + Email: "testuser@coder.com", + Username: "testuser", + Password: "testpass", } _, err := client.CreateFirstUser(ctx, req) require.NoError(t, err) diff --git a/codersdk/users.go b/codersdk/users.go index c2162a6afd18f..c341a09a85274 100644 --- a/codersdk/users.go +++ b/codersdk/users.go @@ -62,10 +62,9 @@ type UserCountResponse struct { } type CreateFirstUserRequest struct { - Email string `json:"email" validate:"required,email"` - Username string `json:"username" validate:"required,username"` - Password string `json:"password" validate:"required"` - OrganizationName string `json:"organization" validate:"required,username"` + Email string `json:"email" validate:"required,email"` + Username string `json:"username" validate:"required,username"` + Password string `json:"password" validate:"required"` } // CreateFirstUserResponse contains IDs for newly created user info. diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 68362eb1ec265..d985014f94096 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -143,7 +143,6 @@ export interface CreateFirstUserRequest { readonly email: string readonly username: string readonly password: string - readonly organization: string } // From codersdk/users.go diff --git a/site/src/pages/SetupPage/SetupPage.test.tsx b/site/src/pages/SetupPage/SetupPage.test.tsx index 2486926db0211..2344e2e596d70 100644 --- a/site/src/pages/SetupPage/SetupPage.test.tsx +++ b/site/src/pages/SetupPage/SetupPage.test.tsx @@ -12,20 +12,14 @@ const fillForm = async ({ username = "someuser", email = "someone@coder.com", password = "password", - organization = "Coder", }: { username?: string email?: string password?: string - organization?: string } = {}) => { const usernameField = screen.getByLabelText(PageViewLanguage.usernameLabel) const emailField = screen.getByLabelText(PageViewLanguage.emailLabel) const passwordField = screen.getByLabelText(PageViewLanguage.passwordLabel) - const organizationField = screen.getByLabelText( - PageViewLanguage.organizationLabel, - ) - await userEvent.type(organizationField, organization) await userEvent.type(usernameField, username) await userEvent.type(emailField, email) await userEvent.type(passwordField, password) diff --git a/site/src/pages/SetupPage/SetupPageView.tsx b/site/src/pages/SetupPage/SetupPageView.tsx index 9e8656a581bd6..99be5c9443215 100644 --- a/site/src/pages/SetupPage/SetupPageView.tsx +++ b/site/src/pages/SetupPage/SetupPageView.tsx @@ -13,11 +13,9 @@ export const Language = { emailLabel: "Email", passwordLabel: "Password", usernameLabel: "Username", - organizationLabel: "Organization name", emailInvalid: "Please enter a valid email address.", emailRequired: "Please enter an email address.", passwordRequired: "Please enter a password.", - organizationRequired: "Please enter an organization name.", create: "Setup account", welcomeMessage: ( <> @@ -32,7 +30,6 @@ const validationSchema = Yup.object({ .email(Language.emailInvalid) .required(Language.emailRequired), password: Yup.string().required(Language.passwordRequired), - organization: Yup.string().required(Language.organizationRequired), username: nameValidator(Language.usernameLabel), }) @@ -55,7 +52,6 @@ export const SetupPageView: React.FC = ({ email: "", password: "", username: "", - organization: "", }, validationSchema, onSubmit, @@ -70,14 +66,6 @@ export const SetupPageView: React.FC = ({
- Date: Fri, 11 Nov 2022 06:03:02 +0000 Subject: [PATCH 2/2] ditch dangler --- coderd/users_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/coderd/users_test.go b/coderd/users_test.go index 951c455206195..b56790de7c78d 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -191,10 +191,9 @@ func TestPostLogin(t *testing.T) { defer cancel() req := codersdk.CreateFirstUserRequest{ - Email: "testuser@coder.com", - Username: "testuser", - Password: "testpass", - OrganizationName: "testorg", + Email: "testuser@coder.com", + Username: "testuser", + Password: "testpass", } _, err := client.CreateFirstUser(ctx, req) require.NoError(t, err)