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