@@ -149,25 +149,28 @@ func (s OrgStatus) String() string {
149149}
150150
151151// GetUserOrgStatus takes a GitHub username, and checks the GitHub API to see
152- // whether that member is part of the Coder organization
153- func (gc * Client ) GetUserOrgStatus (org string , username string ) (OrgStatus , error ) {
152+ // whether that member is part of the provided organization
153+ func (gc * Client ) GetUserOrgStatus (orgName string , username string ) (OrgStatus , error ) {
154154 // This API endpoint is really annoying, because it's able to produce false
155- // negatives. Any user can be a public member of Coder, a private member of
156- // Coder, or a non-member.
155+ // negatives. Any user can be:
156+ // 1. A public member of an organization
157+ // 2. A private member of an organization
158+ // 3. Not a member of an organization
157159 //
158160 // So if the function returns status 200, you can always trust that. But if
159161 // it returns any 400 code, that could indicate a few things:
160- // 1. The user being checked is not part of the organization, but the user
161- // associated with the token is .
162- // 2. The user being checked is a member of the organization, but their
163- // status is private , and the token being used to check belongs to a user
164- // who is not part of the Coder organization .
162+ // 1. The user associated with the token is a member of the organization,
163+ // and the user being checked is not .
164+ // 2. The user associated with the token is NOT a member of the
165+ // organization , and the member being checked is a private member. The
166+ // token user will have no way to view the private member's status .
165167 // 3. Neither the user being checked nor the user associated with the token
166- // are members of the organization
168+ // are members of the organization.
167169 //
168- // The best option is to make sure that the token being used belongs to a
169- // member of the Coder organization
170- req , err := http .NewRequest ("GET" , fmt .Sprintf ("%sorgs/%s/%s" , gc .baseURL , org , username ), nil )
170+ // The best option to avoid false positives is to make sure that the token
171+ // being used belongs to a member of the organization being checked.
172+ url := fmt .Sprintf ("%sorgs/%s/members/%s" , gc .baseURL , orgName , username )
173+ req , err := http .NewRequest ("GET" , url , nil )
171174 if err != nil {
172175 return OrgStatusIndeterminate , err
173176 }
0 commit comments