@@ -152,7 +152,7 @@ func handleAuthorize(ghClientID, ghClientSecret string, appClient *github.Client
152
152
153
153
log .Printf ("Checking if %v already has repo access\n " , username )
154
154
155
- hasAccess , err := hasUserRepoAccess (client )
155
+ hasAccess , err := hasUserRepoAccess (appClient , username )
156
156
if err != nil {
157
157
http .Error (w , fmt .Sprintf ("Error checking for repo access: %v" , err ), 500 )
158
158
return
@@ -264,23 +264,15 @@ func isUserInEpicOrg(client *github.Client, org string) (bool, error) {
264
264
return true , nil
265
265
}
266
266
267
- func hasUserRepoAccess (client * github.Client ) (bool , error ) {
267
+ func hasUserRepoAccess (client * github.Client , username string ) (bool , error ) {
268
268
ctx := context .Background ()
269
269
270
- _ , _ , err := client .Repositories .Get (ctx , "SatisfactoryModding" , "UnrealEngine" )
271
- if err , ok := err .(* github.ErrorResponse ); ok { // We rely on an implementation bug to check if the user can access a repo
272
- if err .Response .StatusCode == 404 {
273
- return false , nil
274
- }
275
- if err .Response .StatusCode == 403 {
276
- return true , nil
277
- }
278
- }
270
+ isCollaborator , _ , err := client .Repositories .IsCollaborator (ctx , "SatisfactoryModding" , "UnrealEngine" , username )
279
271
if err != nil {
280
272
return false , errors .Wrap (err , "error checking user's repo access" )
281
273
}
282
274
283
- return true , nil
275
+ return isCollaborator , nil
284
276
}
285
277
286
278
func acceptInvitationIfPresent (client * github.Client ) (bool , error ) {
0 commit comments