Skip to content

Commit 68adf8a

Browse files
committed
fixup! feat: add audit logs for dormancy events
1 parent 7d2b532 commit 68adf8a

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ func createAnotherUserRetry(t testing.TB, client *codersdk.Client, organizationI
721721
OrganizationIDs: organizationIDs,
722722
// Always create users as active in tests to ignore an extra audit log
723723
// when logging in.
724-
UserStatus: codersdk.UserStatusActive,
724+
UserStatus: ptr.Ref(codersdk.UserStatusActive),
725725
}
726726
for _, m := range mutators {
727727
m(&req)

coderd/users.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/coder/coder/v2/coderd/searchquery"
2929
"github.com/coder/coder/v2/coderd/telemetry"
3030
"github.com/coder/coder/v2/coderd/userpassword"
31+
"github.com/coder/coder/v2/coderd/util/ptr"
3132
"github.com/coder/coder/v2/coderd/util/slice"
3233
"github.com/coder/coder/v2/codersdk"
3334
)
@@ -192,7 +193,7 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
192193
Username: createUser.Username,
193194
Name: createUser.Name,
194195
Password: createUser.Password,
195-
UserStatus: codersdk.UserStatusActive,
196+
UserStatus: ptr.Ref(codersdk.UserStatusActive),
196197
OrganizationIDs: []uuid.UUID{defaultOrg.ID},
197198
},
198199
LoginType: database.LoginTypePassword,
@@ -1346,6 +1347,10 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
13461347
err := store.InTx(func(tx database.Store) error {
13471348
orgRoles := make([]string, 0)
13481349

1350+
status := ""
1351+
if req.UserStatus != nil {
1352+
status = string(*req.UserStatus)
1353+
}
13491354
params := database.InsertUserParams{
13501355
ID: uuid.New(),
13511356
Email: req.Email,
@@ -1357,7 +1362,7 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
13571362
// All new users are defaulted to members of the site.
13581363
RBACRoles: []string{},
13591364
LoginType: req.LoginType,
1360-
Status: string(req.UserStatus),
1365+
Status: status,
13611366
}
13621367
// If a user signs up with OAuth, they can have no password!
13631368
if req.Password != "" {

coderd/users_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/coder/coder/v2/coderd/database/dbgen"
3131
"github.com/coder/coder/v2/coderd/database/dbtime"
3232
"github.com/coder/coder/v2/coderd/rbac"
33+
"github.com/coder/coder/v2/coderd/util/ptr"
3334
"github.com/coder/coder/v2/coderd/util/slice"
3435
"github.com/coder/coder/v2/codersdk"
3536
"github.com/coder/coder/v2/testutil"
@@ -724,7 +725,7 @@ func TestPostUsers(t *testing.T) {
724725
Email: "another@user.org",
725726
Username: "someone-else",
726727
Password: "SomeSecurePassword!",
727-
UserStatus: codersdk.UserStatusActive,
728+
UserStatus: ptr.Ref(codersdk.UserStatusActive),
728729
})
729730
require.NoError(t, err)
730731

codersdk/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ type CreateUserRequestWithOrgs struct {
140140
// UserLoginType defaults to LoginTypePassword.
141141
UserLoginType LoginType `json:"login_type"`
142142
// UserStatus defaults to UserStatusDormant.
143-
UserStatus UserStatus `json:"user_status"`
143+
UserStatus *UserStatus `json:"user_status"`
144144
// OrganizationIDs is a list of organization IDs that the user should be a member of.
145145
OrganizationIDs []uuid.UUID `json:"organization_ids" validate:"" format:"uuid"`
146146
}

site/e2e/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const createUser = async (orgId: string) => {
3737
password: "s3cure&password!",
3838
login_type: "password",
3939
organization_ids: [orgId],
40-
user_status: "dormant"
4140
});
4241
return user;
4342
};

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)