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

Commitacda012

Browse files
committed
Revert "fix: assign new oauth users to default org"
This reverts commit872f4a2.
1 parent872f4a2 commitacda012

25 files changed

+37
-191
lines changed

‎coderd/apidoc/docs.go

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

‎coderd/apidoc/swagger.json

Lines changed: 1 addition & 4 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: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,12 +1016,6 @@ func (q *querier) GetDERPMeshKey(ctx context.Context) (string, error) {
10161016
returnq.db.GetDERPMeshKey(ctx)
10171017
}
10181018

1019-
func (q*querier)GetDefaultOrganization(ctx context.Context) (database.Organization,error) {
1020-
returnfetch(q.log,q.auth,func(ctx context.Context,_any) (database.Organization,error) {
1021-
returnq.db.GetDefaultOrganization(ctx)
1022-
})(ctx,nil)
1023-
}
1024-
10251019
func (q*querier)GetDefaultProxyConfig(ctx context.Context) (database.GetDefaultProxyConfigRow,error) {
10261020
// No authz checks
10271021
returnq.db.GetDefaultProxyConfig(ctx)

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,6 @@ func (s *MethodTestSuite) TestOrganization() {
570570
o:=dbgen.Organization(s.T(),db, database.Organization{})
571571
check.Args(o.ID).Asserts(o,rbac.ActionRead).Returns(o)
572572
}))
573-
s.Run("GetDefaultOrganization",s.Subtest(func(db database.Store,check*expects) {
574-
o:=dbgen.Organization(s.T(),db, database.Organization{})
575-
check.Args().Asserts(o,rbac.ActionRead).Returns(o)
576-
}))
577573
s.Run("GetOrganizationByName",s.Subtest(func(db database.Store,check*expects) {
578574
o:=dbgen.Organization(s.T(),db, database.Organization{})
579575
check.Args(o.Name).Asserts(o,rbac.ActionRead).Returns(o)

‎coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,18 +1657,6 @@ func (q *FakeQuerier) GetDERPMeshKey(_ context.Context) (string, error) {
16571657
returnq.derpMeshKey,nil
16581658
}
16591659

1660-
func (q*FakeQuerier)GetDefaultOrganization(_ context.Context) (database.Organization,error) {
1661-
q.mutex.RLock()
1662-
deferq.mutex.RUnlock()
1663-
1664-
for_,org:=rangeq.organizations {
1665-
iforg.IsDefault {
1666-
returnorg,nil
1667-
}
1668-
}
1669-
return database.Organization{},sql.ErrNoRows
1670-
}
1671-
16721660
func (q*FakeQuerier)GetDefaultProxyConfig(_ context.Context) (database.GetDefaultProxyConfigRow,error) {
16731661
return database.GetDefaultProxyConfigRow{
16741662
DisplayName:q.defaultProxyDisplayName,
@@ -5297,7 +5285,6 @@ func (q *FakeQuerier) InsertOrganization(_ context.Context, arg database.InsertO
52975285
Name:arg.Name,
52985286
CreatedAt:arg.CreatedAt,
52995287
UpdatedAt:arg.UpdatedAt,
5300-
IsDefault:len(q.organizations)==0,
53015288
}
53025289
q.organizations=append(q.organizations,organization)
53035290
returnorganization,nil

‎coderd/database/dbmetrics/dbmetrics.go

Lines changed: 0 additions & 7 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: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dump.sql

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

‎coderd/database/models.go

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

‎coderd/database/querier.go

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

‎coderd/database/querier_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -494,34 +494,6 @@ func TestUserChangeLoginType(t *testing.T) {
494494
require.Equal(t,bobExpPass,bob.HashedPassword,"hashed password should not change")
495495
}
496496

497-
funcTestDefaultOrg(t*testing.T) {
498-
t.Parallel()
499-
iftesting.Short() {
500-
t.SkipNow()
501-
}
502-
503-
sqlDB:=testSQLDB(t)
504-
err:=migrations.Up(sqlDB)
505-
require.NoError(t,err)
506-
db:=database.New(sqlDB)
507-
ctx:=context.Background()
508-
509-
// Should start with 0 orgs
510-
all,err:=db.GetOrganizations(ctx)
511-
require.NoError(t,err)
512-
require.Len(t,all,0)
513-
514-
org,err:=db.InsertOrganization(ctx, database.InsertOrganizationParams{
515-
ID:uuid.New(),
516-
Name:"default",
517-
Description:"",
518-
CreatedAt:dbtime.Now(),
519-
UpdatedAt:dbtime.Now(),
520-
})
521-
require.NoError(t,err)
522-
require.True(t,org.IsDefault,"first org should always be default")
523-
}
524-
525497
typetvArgsstruct {
526498
Status database.ProvisionerJobStatus
527499
// CreateWorkspace is true if we should create a workspace for the template version

‎coderd/database/queries.sql.go

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

‎coderd/database/queries/organizations.sql

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
-- name: GetDefaultOrganization :one
2-
SELECT
3-
*
4-
FROM
5-
organizations
6-
WHERE
7-
is_default= true
8-
LIMIT
9-
1;
10-
111
-- name: GetOrganizations :many
122
SELECT
133
*
@@ -49,7 +39,6 @@ WHERE
4939

5040
-- name: InsertOrganization :one
5141
INSERT INTO
52-
organizations (id,"name", description, created_at, updated_at, is_default)
42+
organizations (id,"name", description, created_at, updated_at)
5343
VALUES
54-
-- If no organizations exist, and this is the first, make it the default.
55-
($1, $2, $3, $4, $5, (SELECT TRUEFROM organizationsLIMIT1) ISNULL) RETURNING*;
44+
($1, $2, $3, $4, $5) RETURNING*;

‎coderd/database/unique_constraint.go

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

‎coderd/organizations.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,5 @@ func convertOrganization(organization database.Organization) codersdk.Organizati
118118
Name:organization.Name,
119119
CreatedAt:organization.CreatedAt,
120120
UpdatedAt:organization.UpdatedAt,
121-
IsDefault:organization.IsDefault,
122121
}
123122
}

‎coderd/organizations_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ func TestOrganizationsByUser(t *testing.T) {
2424
require.NoError(t,err)
2525
require.NotNil(t,orgs)
2626
require.Len(t,orgs,1)
27-
require.True(t,orgs[0].IsDefault,"first org is always default")
28-
29-
// Make an extra org, and it should not be defaulted.
30-
notDefault,err:=client.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{
31-
Name:"another",
32-
})
33-
require.NoError(t,err)
34-
require.False(t,notDefault.IsDefault,"only 1 default org allowed")
3527
}
3628

3729
funcTestOrganizationByUserAndName(t*testing.T) {

‎coderd/userauth.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,12 +1343,13 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13431343
ifuser.ID==uuid.Nil {
13441344
varorganizationID uuid.UUID
13451345
//nolint:gocritic
1346-
organization,_:=tx.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))
1347-
1348-
// Add the user to the default organization.
1349-
// Once multi-organization we should check some configuration to see
1350-
// if we should add the user to a different organization.
1351-
organizationID=organization.ID
1346+
organizations,_:=tx.GetOrganizations(dbauthz.AsSystemRestricted(ctx))
1347+
iflen(organizations)>0 {
1348+
// Add the user to the first organization. Once multi-organization
1349+
// support is added, we should enable a configuration map of user
1350+
// email to organization.
1351+
organizationID=organizations[0].ID
1352+
}
13521353

13531354
//nolint:gocritic
13541355
_,err:=tx.GetUserByEmailOrUsername(dbauthz.AsSystemRestricted(ctx), database.GetUserByEmailOrUsernameParams{
@@ -1394,7 +1395,7 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13941395
// All of the userauth tests depend on this being able to create
13951396
// the first organization. It shouldn't be possible in normal
13961397
// operation.
1397-
CreateOrganization:organizationID==uuid.Nil,
1398+
CreateOrganization:len(organizations)==0,
13981399
LoginType:params.LoginType,
13991400
})
14001401
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp