Skip to content

Commit

Permalink
Merge pull request #123 from opentofu/user_in_personal_org_check
Browse files Browse the repository at this point in the history
Fix GitHub organization membership check, In case of personal GitHub organization
  • Loading branch information
cam72cam authored Dec 20, 2023
2 parents a160bfa + 26a3ab5 commit cbd9ebd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/internal/github/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
)

func (c Client) IsUserInOrganization(username string, org string) (bool, error) {
// First of all, check if the organization is the user's personal GitHub organization
// Here, we can simply check if the username is identical to the organization name
if username == org {
return true, nil
}

// user/org is not case sensitive here
check_url := fmt.Sprintf("https://api.github.com/orgs/%s/public_members/%s", org, username)

Expand Down

0 comments on commit cbd9ebd

Please sign in to comment.