mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
68bfab2fb3
* start feature flags * base feature events on domain const * setup default features * allow setting feature in system api * allow setting feature in admin api * set settings in login based on feature * fix rebasing * unit tests * i18n * update policy after domain discovery * some changes from review * check feature and value type * check feature and value type
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
|
|
object_pb "github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/errors"
|
|
system_pb "github.com/zitadel/zitadel/pkg/grpc/system"
|
|
)
|
|
|
|
func (s *Server) SetInstanceFeature(ctx context.Context, req *system_pb.SetInstanceFeatureRequest) (*system_pb.SetInstanceFeatureResponse, error) {
|
|
details, err := s.setInstanceFeature(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &system_pb.SetInstanceFeatureResponse{
|
|
Details: object_pb.DomainToChangeDetailsPb(details),
|
|
}, nil
|
|
|
|
}
|
|
|
|
func (s *Server) setInstanceFeature(ctx context.Context, req *system_pb.SetInstanceFeatureRequest) (*domain.ObjectDetails, error) {
|
|
feat := domain.Feature(req.FeatureId)
|
|
if !feat.IsAFeature() {
|
|
return nil, errors.ThrowInvalidArgument(nil, "SYST-SGV45", "Errors.Feature.NotExisting")
|
|
}
|
|
switch t := req.Value.(type) {
|
|
case *system_pb.SetInstanceFeatureRequest_Bool:
|
|
return s.command.SetBooleanInstanceFeature(ctx, feat, t.Bool)
|
|
default:
|
|
return nil, errors.ThrowInvalidArgument(nil, "SYST-dag5g", "Errors.Feature.TypeNotSupported")
|
|
}
|
|
}
|