Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e36082

Browse files
kylecarbsEmyrk
andauthored
chore: add github.com user id association (#14045)
* chore: add github.com user id associationThis will eventually be used to show an indicator in the UIto star the repository if you've been using Coder for a whileand have not starred the repo.If you have, we'll never show a thing!* gen* Fix model query* Fix linting* Ignore auditing github.com user id* Add test* Fix gh url var name* Update migration* Update coderd/database/dbauthz/dbauthz.goCo-authored-by: Steven Masley <Emyrk@users.noreply.github.com>* Fix updating to when the token changes* Fix migration---------Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
1 parent4d4d27c commit6e36082

File tree

25 files changed

+222
-37
lines changed

25 files changed

+222
-37
lines changed

‎coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,6 +3260,23 @@ func (q *querier) UpdateUserDeletedByID(ctx context.Context, id uuid.UUID) error
32603260
returndeleteQ(q.log,q.auth,q.db.GetUserByID,q.db.UpdateUserDeletedByID)(ctx,id)
32613261
}
32623262

3263+
func (q*querier)UpdateUserGithubComUserID(ctx context.Context,arg database.UpdateUserGithubComUserIDParams)error {
3264+
user,err:=q.db.GetUserByID(ctx,arg.ID)
3265+
iferr!=nil {
3266+
returnerr
3267+
}
3268+
3269+
err=q.authorizeContext(ctx,policy.ActionUpdatePersonal,user)
3270+
iferr!=nil {
3271+
// System user can also update
3272+
err=q.authorizeContext(ctx,policy.ActionUpdate,user)
3273+
iferr!=nil {
3274+
returnerr
3275+
}
3276+
}
3277+
returnq.db.UpdateUserGithubComUserID(ctx,arg)
3278+
}
3279+
32633280
func (q*querier)UpdateUserHashedPassword(ctx context.Context,arg database.UpdateUserHashedPasswordParams)error {
32643281
user,err:=q.db.GetUserByID(ctx,arg.ID)
32653282
iferr!=nil {

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,12 @@ func (s *MethodTestSuite) TestUser() {
11051105
u:=dbgen.User(s.T(),db, database.User{})
11061106
check.Args(u.ID).Asserts(u,policy.ActionDelete).Returns()
11071107
}))
1108+
s.Run("UpdateUserGithubComUserID",s.Subtest(func(db database.Store,check*expects) {
1109+
u:=dbgen.User(s.T(),db, database.User{})
1110+
check.Args(database.UpdateUserGithubComUserIDParams{
1111+
ID:u.ID,
1112+
}).Asserts(u,policy.ActionUpdatePersonal)
1113+
}))
11081114
s.Run("UpdateUserHashedPassword",s.Subtest(func(db database.Store,check*expects) {
11091115
u:=dbgen.User(s.T(),db, database.User{})
11101116
check.Args(database.UpdateUserHashedPasswordParams{

‎coderd/database/dbmem/dbmem.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7985,6 +7985,26 @@ func (q *FakeQuerier) UpdateUserDeletedByID(_ context.Context, id uuid.UUID) err
79857985
returnsql.ErrNoRows
79867986
}
79877987

7988+
func (q*FakeQuerier)UpdateUserGithubComUserID(_ context.Context,arg database.UpdateUserGithubComUserIDParams)error {
7989+
err:=validateDatabaseType(arg)
7990+
iferr!=nil {
7991+
returnerr
7992+
}
7993+
7994+
q.mutex.Lock()
7995+
deferq.mutex.Unlock()
7996+
7997+
fori,user:=rangeq.users {
7998+
ifuser.ID!=arg.ID {
7999+
continue
8000+
}
8001+
user.GithubComUserID=arg.GithubComUserID
8002+
q.users[i]=user
8003+
returnnil
8004+
}
8005+
returnsql.ErrNoRows
8006+
}
8007+
79888008
func (q*FakeQuerier)UpdateUserHashedPassword(_ context.Context,arg database.UpdateUserHashedPasswordParams)error {
79898009
iferr:=validateDatabaseType(arg);err!=nil {
79908010
returnerr

‎coderd/database/dbmetrics/dbmetrics.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dump.sql

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTERTABLE users DROP COLUMN github_com_user_id;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTERTABLE users ADD COLUMN github_com_user_idBIGINT;
2+
3+
COMMENT ON COLUMN users.github_com_user_id IS'The GitHub.com numerical user ID. At time of implementation, this is used to check if the user has starred the Coder repository.';

‎coderd/database/modelqueries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ func (q *sqlQuerier) GetAuthorizedUsers(ctx context.Context, arg GetUsersParams,
361361
&i.QuietHoursSchedule,
362362
&i.ThemePreference,
363363
&i.Name,
364+
&i.GithubComUserID,
364365
&i.Count,
365366
);err!=nil {
366367
returnnil,err

‎coderd/database/models.go

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

‎coderd/database/querier.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp