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

feat: use default org for PostUser#12143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 1 commit intomainfromstevenmasley/post_user
Feb 16, 2024
Merged

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedFeb 14, 2024
edited
Loading

Closes#11925

What this does

Instead of assuming only 1 org exists, this uses theis_default org to place a user in if not specified.

@EmyrkGraphite App
Copy link
MemberAuthor

Emyrk commentedFeb 14, 2024
edited
Loading

@EmyrkEmyrkforce-pushed thestevenmasley/post_user branch from01ec5d8 tobdd0956CompareFebruary 14, 2024 17:01
Comment on lines -404 to +423
// If no organization is provided, add the user to the first
// organization.
organizations,err:=api.Database.GetOrganizations(ctx)
// If no organization is provided, add the user to the default
defaultOrg,err:=api.Database.GetDefaultOrganization(ctx)
iferr!=nil {
ifhttpapi.Is404Error(err) {
httpapi.Write(ctx,rw,http.StatusNotFound,
codersdk.Response{
Message:"Resource not found or you do not have access to this resource",
Detail:"Organization not found",
},
)
return
}
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
Message:"Internal error fetching orgs.",
Detail:err.Error(),
})
return
}

iflen(organizations)>0 {
// Add the user to the first organization. Once multi-organization
// support is added, we should enable a configuration map of user
// email to organization.
req.OrganizationID=organizations[0].ID
}
req.OrganizationID=defaultOrg.ID
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is the change

@EmyrkEmyrk marked this pull request as ready for reviewFebruary 14, 2024 17:45
@EmyrkEmyrkforce-pushed thestevenmasley/post_user branch from60775a6 to04c6149CompareFebruary 14, 2024 18:08
@EmyrkEmyrk requested a review frommafredriFebruary 15, 2024 15:30
@EmyrkEmyrkforce-pushed thestevenmasley/default_org branch from0f27fcc to5bb0ffcCompareFebruary 15, 2024 16:28
@EmyrkEmyrkforce-pushed thestevenmasley/post_user branch from04c6149 to7059828CompareFebruary 15, 2024 16:28
Base automatically changed fromstevenmasley/default_org tomainFebruary 15, 2024 17:01
@EmyrkEmyrkforce-pushed thestevenmasley/post_user branch from7059828 toa25537eCompareFebruary 15, 2024 17:12
@EmyrkEmyrk changed the base branch frommain tostevenmasley/default_orgFebruary 15, 2024 17:13
@EmyrkEmyrk changed the base branch fromstevenmasley/default_org tomainFebruary 15, 2024 17:13
Instead of assuming only 1 org exists, this uses theis_default org to place a user in if not specified.
@EmyrkEmyrkforce-pushed thestevenmasley/post_user branch fromaeb29f2 to8f61a71CompareFebruary 15, 2024 17:18
@@ -1016,6 +1016,12 @@ func (q *querier) GetDERPMeshKey(ctx context.Context) (string, error) {
return q.db.GetDERPMeshKey(ctx)
}

func (q *querier) GetDefaultOrganization(ctx context.Context) (database.Organization, error) {
return fetch(q.log, q.auth, func(ctx context.Context, _ any) (database.Organization, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No need for auth here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That does do auth!fetch is the helper function that automatically checks the RBAC on the returned object. So if the caller cannot read the default org, this will fail.

@EmyrkEmyrk merged commit2a8004b intomainFeb 16, 2024
@EmyrkEmyrk deleted the stevenmasley/post_user branchFebruary 16, 2024 14:28
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 16, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

PostUser requires organization
2 participants
@Emyrk@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp