Add auto-assign groups to the User API (#467)

This commit is contained in:
Misha Bragin
2022-09-22 09:06:32 +02:00
committed by GitHub
parent c75ffd0f4b
commit 518a2561a2
8 changed files with 304 additions and 65 deletions

View File

@@ -330,6 +330,13 @@ func (am *DefaultAccountManager) AddPeer(
if err != nil {
return nil, status.Errorf(codes.NotFound, "unable to register peer, unknown user with ID: %s", userID)
}
user, ok := account.Users[userID]
if !ok {
return nil, status.Errorf(codes.NotFound, "unable to register peer, unknown user with ID: %s", userID)
}
groupsToAdd = user.AutoGroups
} else {
// Empty setup key and jwt fail
return nil, status.Errorf(codes.InvalidArgument, "no setup key or user id provided")