MCPcopy Index your code
hub / github.com/rilldata/rill / isCollaborator

Method isCollaborator

admin/server/github.go:1001–1018  ·  view source on GitHub ↗

isCollaborator checks if the user is a collaborator of the repository identified by owner and repo client must be authorized with user's auth token

(ctx context.Context, owner, repo string, client *github.Client, user *github.User)

Source from the content-addressed store, hash-verified

999// isCollaborator checks if the user is a collaborator of the repository identified by owner and repo
1000// client must be authorized with user's auth token
1001func (s *Server) isCollaborator(ctx context.Context, owner, repo string, client *github.Client, user *github.User) (bool, error) {
1002 githubUserName := user.GetLogin()
1003 // repo belongs to the user's personal account
1004 if owner == githubUserName {
1005 return true, nil
1006 }
1007
1008 // repo belongs to an org
1009 isCollaborator, resp, err := client.Repositories.IsCollaborator(ctx, owner, repo, user.GetLogin())
1010 if err != nil {
1011 // user client does not have access to the repository
1012 if resp != nil && (resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden) {
1013 return false, nil
1014 }
1015 return false, err
1016 }
1017 return isCollaborator, nil
1018}
1019
1020func (s *Server) redirectLogin(w http.ResponseWriter, r *http.Request) {
1021 redirectURL := s.admin.URLs.AuthLogin(r.URL.RequestURI(), false)

Callers 2

githubConnectCallbackMethod · 0.95
githubAuthCallbackMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected