gateway: update CreateProject api
remove currentuserid since we can get it directly in the action
This commit is contained in:
parent
e1d0318c9b
commit
a43be4a6be
|
@ -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 == "" {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue