diff --git a/pkg/common/storage/database/mgo/user.go b/pkg/common/storage/database/mgo/user.go index 5a2dc7e34..ef599b782 100644 --- a/pkg/common/storage/database/mgo/user.go +++ b/pkg/common/storage/database/mgo/user.go @@ -63,7 +63,15 @@ func (u *UserMgo) UpdateByMap(ctx context.Context, userID string, args map[strin if len(args) == 0 { return nil } - return mongoutil.UpdateOne(ctx, u.coll, bson.M{"user_id": userID}, bson.M{"$set": args}, true) + filter := bson.M{"user_id": userID} + update := bson.M{"$set": args} + if err := mongoutil.UpdateOne(ctx, u.coll, filter, update, true); err != nil { + return err + } + + // Keep user attributes in sync for consumers that read from the "attribute" collection. + attributeColl := u.coll.Database().Collection("attribute") + return mongoutil.UpdateOne(ctx, attributeColl, filter, update, true) } func (u *UserMgo) Find(ctx context.Context, userIDs []string) (users []*model.User, err error) {