Skip to content

Commit e84b893

Browse files
committed
fixup! feat: add audit logs for dormancy events
1 parent e137e92 commit e84b893

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7709,6 +7709,11 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
77097709
}
77107710
}
77117711

7712+
status := database.UserStatusDormant
7713+
if arg.Status != "" {
7714+
status = arg.Status
7715+
}
7716+
77127717
user := database.User{
77137718
ID: arg.ID,
77147719
Email: arg.Email,
@@ -7717,7 +7722,7 @@ func (q *FakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
77177722
UpdatedAt: arg.UpdatedAt,
77187723
Username: arg.Username,
77197724
Name: arg.Name,
7720-
Status: database.UserStatusDormant,
7725+
Status: status,
77217726
RBACRoles: arg.RBACRoles,
77227727
LoginType: arg.LoginType,
77237728
}
@@ -8640,6 +8645,7 @@ func (q *FakeQuerier) UpdateInactiveUsersToDormant(_ context.Context, params dat
86408645
updated = append(updated, database.UpdateInactiveUsersToDormantRow{
86418646
ID: user.ID,
86428647
Email: user.Email,
8648+
Username: user.Username,
86438649
LastSeenAt: user.LastSeenAt,
86448650
})
86458651
}

coderd/database/queries.sql.go

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/users.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ INSERT INTO
6767
created_at,
6868
updated_at,
6969
rbac_roles,
70-
login_type
70+
login_type,
71+
status
7172
)
7273
VALUES
73-
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *;
74+
($1, $2, $3, $4, $5, $6, $7, $8, $9, NULLIF(@status::user_status, '')) RETURNING *;
7475

7576
-- name: UpdateUserProfile :one
7677
UPDATE

coderd/users.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ func (api *API) organizationByUserAndName(rw http.ResponseWriter, r *http.Reques
13281328
type CreateUserRequest struct {
13291329
codersdk.CreateUserRequestWithOrgs
13301330
LoginType database.LoginType
1331+
Status database.UserStatus
13311332
SkipNotifications bool
13321333
accountCreatorName string
13331334
}
@@ -1354,6 +1355,7 @@ func (api *API) CreateUser(ctx context.Context, store database.Store, req Create
13541355
// All new users are defaulted to members of the site.
13551356
RBACRoles: []string{},
13561357
LoginType: req.LoginType,
1358+
Status: req.Status,
13571359
}
13581360
// If a user signs up with OAuth, they can have no password!
13591361
if req.Password != "" {

0 commit comments

Comments
 (0)