diff --git a/internal/services/gateway/action/project.go b/internal/services/gateway/action/project.go index c70a7b4..8903678 100644 --- a/internal/services/gateway/action/project.go +++ b/internal/services/gateway/action/project.go @@ -49,7 +49,6 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa } type CreateProjectRequest struct { - CurrentUserID string Name string ParentRef string Visibility types.Visibility @@ -59,9 +58,11 @@ type CreateProjectRequest struct { } func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectRequest) (*csapi.Project, error) { - user, resp, err := h.configstoreClient.GetUser(ctx, req.CurrentUserID) + curUserID := h.CurrentUserID(ctx) + + user, resp, err := h.configstoreClient.GetUser(ctx, curUserID) if err != nil { - return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get user %q", req.CurrentUserID)) + return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get user %q", curUserID)) } parentRef := req.ParentRef if parentRef == "" { diff --git a/internal/services/gateway/api/project.go b/internal/services/gateway/api/project.go index 79fd28c..ec892d7 100644 --- a/internal/services/gateway/api/project.go +++ b/internal/services/gateway/api/project.go @@ -19,7 +19,6 @@ import ( "net/http" "net/url" - "github.com/pkg/errors" csapi "github.com/sorintlab/agola/internal/services/configstore/api" "github.com/sorintlab/agola/internal/services/gateway/action" "github.com/sorintlab/agola/internal/services/types" @@ -58,21 +57,12 @@ func (h *CreateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) return } - userIDVal := ctx.Value("userid") - if userIDVal == nil { - httpError(w, util.NewErrBadRequest(errors.Errorf("user not authenticated"))) - return - } - userID := userIDVal.(string) - h.log.Infof("userID: %q", userID) - areq := &action.CreateProjectRequest{ Name: req.Name, ParentRef: req.ParentRef, Visibility: req.Visibility, RepoPath: req.RepoPath, RemoteSourceName: req.RemoteSourceName, - CurrentUserID: userID, SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck, }