mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-29 06:18:42 +02:00
Allow to update IntegrationReference for user (#1308)
This should not happen via an API but be possible when calling the method directly.
This commit is contained in:
parent
d1d01a0611
commit
70c7543e36
@ -363,7 +363,7 @@ func (am *DefaultAccountManager) GetUser(claims jwtclaims.AuthorizationClaims) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListUsers returns lists of all users under the account.
|
// ListUsers returns lists of all users under the account.
|
||||||
// It doesn't populate user information such a email or name.
|
// It doesn't populate user information such as email or name.
|
||||||
func (am *DefaultAccountManager) ListUsers(accountID string) ([]*User, error) {
|
func (am *DefaultAccountManager) ListUsers(accountID string) ([]*User, error) {
|
||||||
unlock := am.Store.AcquireAccountLock(accountID)
|
unlock := am.Store.AcquireAccountLock(accountID)
|
||||||
defer unlock()
|
defer unlock()
|
||||||
@ -713,7 +713,7 @@ func (am *DefaultAccountManager) SaveOrAddUser(accountID, initiatorUserID string
|
|||||||
if !addIfNotExists {
|
if !addIfNotExists {
|
||||||
return nil, status.Errorf(status.NotFound, "user to update doesn't exist")
|
return nil, status.Errorf(status.NotFound, "user to update doesn't exist")
|
||||||
}
|
}
|
||||||
// will add a user based on input
|
// when addIfNotExists is set to true the newUser will use all fields from the update input
|
||||||
oldUser = update
|
oldUser = update
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,11 +725,13 @@ func (am *DefaultAccountManager) SaveOrAddUser(accountID, initiatorUserID string
|
|||||||
return nil, status.Errorf(status.PermissionDenied, "admins can't change their role")
|
return nil, status.Errorf(status.PermissionDenied, "admins can't change their role")
|
||||||
}
|
}
|
||||||
|
|
||||||
// only auto groups, revoked status, and name can be updated for now
|
// only auto groups, revoked status, and integration reference can be updated for now
|
||||||
// when addIfNotExists is set to true the newUser will use all fields from the update input
|
|
||||||
newUser := oldUser.Copy()
|
newUser := oldUser.Copy()
|
||||||
newUser.Role = update.Role
|
newUser.Role = update.Role
|
||||||
newUser.Blocked = update.Blocked
|
newUser.Blocked = update.Blocked
|
||||||
|
// these two fields can't be set via API, only via direct call to the method
|
||||||
|
newUser.Issued = update.Issued
|
||||||
|
newUser.IntegrationReference = update.IntegrationReference
|
||||||
|
|
||||||
for _, newGroupID := range update.AutoGroups {
|
for _, newGroupID := range update.AutoGroups {
|
||||||
if _, ok := account.Groups[newGroupID]; !ok {
|
if _, ok := account.Groups[newGroupID]; !ok {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user