Update API codes (#336)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-08 23:57:26 -04:00
1 parent 99d5456d7a
commit f94f21fd97
74 files changed
+1557 -1802

No files matched your search

@@ -130,11 +130,11 @@ func (s Service) DeleteAuthMethod(ctx context.Context, req *pbs.DeleteAuthMethod
if authResults.Error != nil {
return nil, authResults.Error
}
existed, err := s.deleteFromRepo(ctx, authResults.Scope.GetId(), req.GetId())
_, err := s.deleteFromRepo(ctx, authResults.Scope.GetId(), req.GetId())
if err != nil {
return nil, err
}
return &pbs.DeleteAuthMethodResponse{Existed: existed}, nil
return nil, nil
}
func (s Service) getFromRepo(ctx context.Context, id string) (*pb.AuthMethod, error) {
@@ -279,7 +279,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
return res
}
if scp == nil {
res.Error = handlers.ForbiddenError()
res.Error = handlers.NotFoundError()
return res
}
default:
@@ -294,7 +294,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
return res
}
if authMeth == nil {
res.Error = handlers.ForbiddenError()
res.Error = handlers.NotFoundError()
return res
}
parentId = authMeth.GetScopeId()
@@ -382,8 +382,12 @@ func validateDeleteRequest(req *pbs.DeleteAuthMethodRequest) error {
return handlers.ValidateDeleteRequest(password.AuthMethodPrefix, req, handlers.NoopValidatorFn)
}
func validateListRequest(_ *pbs.ListAuthMethodsRequest) error {
func validateListRequest(req *pbs.ListAuthMethodsRequest) error {
badFields := map[string]string{}
if !handlers.ValidId(scope.Org.Prefix(), req.GetScopeId()) &&
req.GetScopeId() != scope.Global.String() {
badFields["scope_id"] = "This field must be a valid project scope id."
}
if len(badFields) > 0 {
return handlers.InvalidArgumentErrorf("Improperly formatted identifier.", badFields)
}