@@ -152,7 +152,7 @@ func handleAuthorize(ghClientID, ghClientSecret string, appClient *github.Client
152152
153153 log .Printf ("Checking if %v already has repo access\n " , username )
154154
155- hasAccess , err := hasUserRepoAccess (client )
155+ hasAccess , err := hasUserRepoAccess (appClient , username )
156156 if err != nil {
157157 http .Error (w , fmt .Sprintf ("Error checking for repo access: %v" , err ), 500 )
158158 return
@@ -264,23 +264,15 @@ func isUserInEpicOrg(client *github.Client, org string) (bool, error) {
264264 return true , nil
265265}
266266
267- func hasUserRepoAccess (client * github.Client ) (bool , error ) {
267+ func hasUserRepoAccess (client * github.Client , username string ) (bool , error ) {
268268 ctx := context .Background ()
269269
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 )
279271 if err != nil {
280272 return false , errors .Wrap (err , "error checking user's repo access" )
281273 }
282274
283- return true , nil
275+ return isCollaborator , nil
284276}
285277
286278func acceptInvitationIfPresent (client * github.Client ) (bool , error ) {
0 commit comments