@@ -477,18 +477,18 @@ func (c *component) GetUsersWithAttribute(ctx context.Context, realmName string,
477477func (c * component ) AddUserAttributes (ctx context.Context , realmName string , userID string , attributes map [string ][]string ) error {
478478 // For now, we don't check which attributes are allowed to be set. If needed, we should use UserProfile feature and
479479 // check if annotations tell that the attribute is writable or not for the given interface.
480- return c .updateUser (ctx , realmName , userID , func (user kc.UserRepresentation ) bool {
480+ return c .updateUser (ctx , realmName , userID , func (user * kc.UserRepresentation ) bool {
481481 var updated = false
482482 for attributeKey , attributeValues := range attributes {
483- if c .addUserAttribute (user , attributeKey , attributeValues ) {
483+ if c .addUserAttribute (ctx , user , attributeKey , attributeValues ) {
484484 updated = true
485485 }
486486 }
487487 return updated
488488 })
489489}
490490
491- func (c * component ) addUserAttribute (user kc.UserRepresentation , attributeKey string , attributeValues []string ) bool {
491+ func (c * component ) addUserAttribute (ctx context. Context , user * kc.UserRepresentation , attributeKey string , attributeValues []string ) bool {
492492 var key = kc .AttributeKey (attributeKey )
493493 if user .Attributes == nil {
494494 var attributes = make (kc.Attributes )
@@ -507,7 +507,7 @@ func (c *component) addUserAttribute(user kc.UserRepresentation, attributeKey st
507507func (c * component ) DeleteUserAttributes (ctx context.Context , realmName string , userID string , attributeKeys []string ) error {
508508 // For now, we don't check which attributes are allowed to be removed. If needed, we should use UserProfile feature and
509509 // check if annotations tell that the attribute is writable or not for the given interface.
510- return c .updateUser (ctx , realmName , userID , func (user kc.UserRepresentation ) bool {
510+ return c .updateUser (ctx , realmName , userID , func (user * kc.UserRepresentation ) bool {
511511 var count = 0
512512 for _ , attributeKey := range attributeKeys {
513513 var key = kc .AttributeKey (attributeKey )
@@ -523,7 +523,7 @@ func (c *component) DeleteUserAttributes(ctx context.Context, realmName string,
523523 })
524524}
525525
526- func (c * component ) updateUser (ctx context.Context , realmName string , userID string , updateFunc func (user kc.UserRepresentation ) bool ) error {
526+ func (c * component ) updateUser (ctx context.Context , realmName string , userID string , updateFunc func (user * kc.UserRepresentation ) bool ) error {
527527 accessToken , err := c .tokenProvider .ProvideTokenForRealm (ctx , realmName )
528528 if err != nil {
529529 c .logger .Warn (ctx , "msg" , "Failed to get OIDC token from keycloak" , "err" , err .Error ())
@@ -534,7 +534,7 @@ func (c *component) updateUser(ctx context.Context, realmName string, userID str
534534 c .logger .Warn (ctx , "msg" , "Failed to get Keycloak user" , "err" , err .Error (), "realm" , realmName , "user" , userID )
535535 return err
536536 }
537- if updateFunc (user ) {
537+ if updateFunc (& user ) {
538538 err = overrideKeycloakError (c .keycloakIdpClient .UpdateUser (accessToken , realmName , userID , user ), "attribute" )
539539 if err != nil {
540540 c .logger .Warn (ctx , "msg" , "Failed to update user from keycloak" , "err" , err .Error (), "realm" , realmName , "user" , userID )
0 commit comments