fix(ui): resolve active profile before GetConfig in GetRestrictions

GetRestrictions called the daemon GetConfig with an empty
GetConfigRequest, which the daemon has rejected since multi-profile
support landed ("active profile name is empty") because it reads the
profile name from the request. Resolve the active profile via
GetActiveProfile first and pass its name/username, mirroring the
working Settings.GetConfig path. GetActiveProfile self-heals to the
default profile, so a valid name is always supplied; the
profile-switch-disabled MDM flag is orthogonal and unaffected.
This commit is contained in:
Zoltan Papp
2026-06-15 12:04:50 +02:00
parent 9e5bcb26eb
commit c68bb8f99f

View File

@@ -4,6 +4,7 @@ package services
import (
"context"
"fmt"
"reflect"
"github.com/netbirdio/netbird/client/proto"
@@ -200,7 +201,14 @@ func (s *Settings) GetRestrictions(ctx context.Context) (Restrictions, error) {
if err != nil {
return Restrictions{}, err
}
cfgResp, err := cli.GetConfig(ctx, &proto.GetConfigRequest{})
active, err := cli.GetActiveProfile(ctx, &proto.GetActiveProfileRequest{})
if err != nil {
return Restrictions{}, fmt.Errorf("get active profile: %w", err)
}
cfgResp, err := cli.GetConfig(ctx, &proto.GetConfigRequest{
ProfileName: active.GetProfileName(),
Username: active.GetUsername(),
})
if err != nil {
return Restrictions{}, err
}