mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 20:28:00 +00:00
chore: tweak feature matrix
This commit is contained in:
@ -218,7 +218,7 @@ func (s *APIV1Service) checkSeatAvailability(ctx context.Context) error {
|
||||
return status.Errorf(codes.Internal, fmt.Sprintf("failed to list users, err: %s", err))
|
||||
}
|
||||
seats := s.LicenseService.GetSubscription().Seats
|
||||
if len(userList) > int(seats) {
|
||||
if len(userList) >= int(seats) {
|
||||
return status.Errorf(codes.FailedPrecondition, "maximum number of users %d reached", seats)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
|
||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
storepb "github.com/yourselfhosted/slash/proto/gen/store"
|
||||
"github.com/yourselfhosted/slash/server/service/license"
|
||||
"github.com/yourselfhosted/slash/store"
|
||||
)
|
||||
|
||||
@ -63,14 +62,8 @@ func (s *APIV1Service) CreateUser(ctx context.Context, request *v1pb.CreateUserR
|
||||
return nil, status.Errorf(codes.Internal, "failed to hash password: %v", err)
|
||||
}
|
||||
|
||||
if !s.LicenseService.IsFeatureEnabled(license.FeatureTypeUnlimitedAccounts) {
|
||||
userList, err := s.Store.ListUsers(ctx, &store.FindUser{})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to list users: %v", err)
|
||||
}
|
||||
if len(userList) >= 5 {
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "maximum number of users reached")
|
||||
}
|
||||
if err := s.checkSeatAvailability(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user, err := s.Store.CreateUser(ctx, &store.User{
|
||||
|
@ -24,6 +24,7 @@ func (s *APIV1Service) GetWorkspaceProfile(ctx context.Context, _ *v1pb.GetWorks
|
||||
// Load subscription plan from license service.
|
||||
subscription := s.LicenseService.GetSubscription()
|
||||
workspaceProfile.Plan = subscription.Plan
|
||||
workspaceProfile.Features = subscription.Features
|
||||
|
||||
owner, err := s.GetInstanceOwner(ctx)
|
||||
if err != nil {
|
||||
|
@ -33,7 +33,8 @@ func NewLicenseService(profile *profile.Profile, store *store.Store) *LicenseSer
|
||||
Profile: profile,
|
||||
Store: store,
|
||||
cachedSubscription: &v1pb.Subscription{
|
||||
Plan: v1pb.PlanType_FREE,
|
||||
Plan: v1pb.PlanType_FREE,
|
||||
Seats: 5,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -45,8 +46,10 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) (*v1pb.Subscripti
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace setting")
|
||||
}
|
||||
|
||||
subscription := &v1pb.Subscription{
|
||||
Plan: v1pb.PlanType_FREE,
|
||||
Plan: v1pb.PlanType_FREE,
|
||||
Seats: 5,
|
||||
}
|
||||
licenseKey := ""
|
||||
if workspaceSettingGeneral != nil {
|
||||
|
Reference in New Issue
Block a user