Skip to content

Commit 575925c

Browse files
feat: add one time passcode columns to users table (#14797)
1 parent bb3850a commit 575925c

File tree

8 files changed

+126
-47
lines changed

8 files changed

+126
-47
lines changed

coderd/database/dump.sql

+11-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE users DROP CONSTRAINT one_time_passcode_set;
2+
3+
ALTER TABLE users DROP COLUMN hashed_one_time_passcode;
4+
ALTER TABLE users DROP COLUMN one_time_passcode_expires_at;
5+
ALTER TABLE users DROP COLUMN must_reset_password;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ALTER TABLE users ADD COLUMN hashed_one_time_passcode bytea;
2+
COMMENT ON COLUMN users.hashed_one_time_passcode IS 'A hash of the one-time-passcode given to the user.';
3+
4+
ALTER TABLE users ADD COLUMN one_time_passcode_expires_at timestamp with time zone;
5+
COMMENT ON COLUMN users.one_time_passcode_expires_at IS 'The time when the one-time-passcode expires.';
6+
7+
ALTER TABLE users ADD CONSTRAINT one_time_passcode_set CHECK (
8+
(hashed_one_time_passcode IS NULL AND one_time_passcode_expires_at IS NULL)
9+
OR (hashed_one_time_passcode IS NOT NULL AND one_time_passcode_expires_at IS NOT NULL)
10+
);
11+
12+
ALTER TABLE users ADD COLUMN must_reset_password bool NOT NULL DEFAULT false;
13+
COMMENT ON COLUMN users.must_reset_password IS 'Determines if the user should be forced to change their password.';

coderd/database/modelqueries.go

+3
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams,
364364
&i.ThemePreference,
365365
&i.Name,
366366
&i.GithubComUserID,
367+
&i.HashedOneTimePasscode,
368+
&i.OneTimePasscodeExpiresAt,
369+
&i.MustResetPassword,
367370
&i.Count,
368371
); err != nil {
369372
return nil, err

coderd/database/models.go

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+68-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)