2023-09-29 08:21:32 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2024-02-28 08:55:54 +00:00
|
|
|
"github.com/muhlemmer/gu"
|
|
|
|
|
2024-03-20 10:18:46 +00:00
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
2023-09-29 08:21:32 +00:00
|
|
|
object_pb "github.com/zitadel/zitadel/internal/api/grpc/object"
|
2024-02-28 08:55:54 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/command"
|
2024-03-20 10:18:46 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
|
|
|
"github.com/zitadel/zitadel/internal/query/projection"
|
2023-09-29 08:21:32 +00:00
|
|
|
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) ActivateFeatureLoginDefaultOrg(ctx context.Context, _ *admin_pb.ActivateFeatureLoginDefaultOrgRequest) (*admin_pb.ActivateFeatureLoginDefaultOrgResponse, error) {
|
2024-02-28 08:55:54 +00:00
|
|
|
details, err := s.command.SetInstanceFeatures(ctx, &command.InstanceFeatures{
|
|
|
|
LoginDefaultOrg: gu.Ptr(true),
|
|
|
|
})
|
2023-09-29 08:21:32 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-03-20 10:18:46 +00:00
|
|
|
_, err = projection.InstanceFeatureProjection.Trigger(ctx, handler.WithAwaitRunning())
|
|
|
|
logging.OnError(err).Warn("trigger instance feature projection")
|
|
|
|
|
2023-09-29 08:21:32 +00:00
|
|
|
return &admin_pb.ActivateFeatureLoginDefaultOrgResponse{
|
|
|
|
Details: object_pb.DomainToChangeDetailsPb(details),
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
}
|