Skip to content

feat(setup): organization is not longer needed #4707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions cli/resetpassword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 3 additions & 4 deletions cli/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 9 additions & 12 deletions coderd/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -192,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)
Expand Down Expand Up @@ -249,10 +247,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)
Expand Down
7 changes: 3 additions & 4 deletions codersdk/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export interface CreateFirstUserRequest {
readonly email: string
readonly username: string
readonly password: string
readonly organization: string
}

// From codersdk/users.go
Expand Down
6 changes: 0 additions & 6 deletions site/src/pages/SetupPage/SetupPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 0 additions & 12 deletions site/src/pages/SetupPage/SetupPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: (
<>
Expand All @@ -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),
})

Expand All @@ -55,7 +52,6 @@ export const SetupPageView: React.FC<SetupPageViewProps> = ({
email: "",
password: "",
username: "",
organization: "",
},
validationSchema,
onSubmit,
Expand All @@ -70,14 +66,6 @@ export const SetupPageView: React.FC<SetupPageViewProps> = ({
<Welcome message={Language.welcomeMessage} />
<form onSubmit={form.handleSubmit}>
<Stack>
<TextField
{...getFieldHelpers("organization")}
onChange={onChangeTrimmed(form)}
autoFocus
fullWidth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to give autoFocus to the next field so that users can start typing without clicking into the form.

label={Language.organizationLabel}
variant="outlined"
/>
<TextField
{...getFieldHelpers("username")}
onChange={onChangeTrimmed(form)}
Expand Down