From dbc6160e8a508965c882c612ddafb3e60145e62f Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 29 Jul 2015 12:25:48 +0200 Subject: [PATCH] Only load user profile if at least one field requesting it --- engine/users.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/engine/users.go b/engine/users.go index 8e937fc83..c0fe01f1c 100644 --- a/engine/users.go +++ b/engine/users.go @@ -355,6 +355,7 @@ func (ps *ProxyUserService) GetIndexes(in string, reply *map[string][]string) er return ps.Client.Call("UsersV1.AddIndex", in, reply) } +// extraFields - Field name in the interface containing extraFields information func LoadUserProfile(in interface{}, extraFields string) (interface{}, error) { if userService == nil { // no user service => no fun return in, nil @@ -363,7 +364,16 @@ func LoadUserProfile(in interface{}, extraFields string) (interface{}, error) { if err != nil { return nil, err } - + var needsUsers bool + for _, val := range m { + if val == utils.USERS { + needsUsers = true + break + } + } + if !needsUsers { // Do not process further if user profile is not needed + return in, nil + } up := &UserProfile{ Profile: make(map[string]string), }