diff options
author | MrArmonius <mrarmonius@gmail.com> | 2021-07-30 16:30:15 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-08-16 12:54:08 +0200 |
commit | f00702b51c8904f9fb42a90a6e22301ae8d4014a (patch) | |
tree | e3d8364b3a51f3498eccf55f9e636114b3005d9b /directory.go | |
parent | a2a484daba1ef42d82f596a989caf203ee9a370f (diff) | |
download | guichet-f00702b51c8904f9fb42a90a6e22301ae8d4014a.tar.gz guichet-f00702b51c8904f9fb42a90a6e22301ae8d4014a.zip |
Correction Review Alex
Change json Identifiant to ID
Diffstat (limited to 'directory.go')
-rw-r--r-- | directory.go | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/directory.go b/directory.go index a66ef28..c36bd41 100644 --- a/directory.go +++ b/directory.go @@ -22,8 +22,8 @@ func handleDirectory(w http.ResponseWriter, r *http.Request) { } type SearchResult struct { - Identifiant string `json:"identifiant"` - Name string `json:"name"` + Id string `json:"id"` + Displayname string `json:"displayname"` Email string `json:"email"` Description string `json:"description"` DN string `json:"dn"` @@ -61,15 +61,16 @@ func handleSearch(w http.ResponseWriter, r *http.Request) { return } - //Transform the researh's result in a correct struct to send HSON + //Transform the researh's result in a correct struct to send JSON var result Results for _, values := range sr.Entries { - if strings.Contains(values.GetAttributeValue("cn"), input) { + if strings.Contains(values.GetAttributeValue(config.UserNameAttr), input) || strings.Contains(values.GetAttributeValue("displayname"), input) || + (values.GetAttributeValue("email") != "" && strings.Contains(values.GetAttributeValue("email"), input)) { result = Results{ Search: append(result.Search, SearchResult{ - Identifiant: values.GetAttributeValue("cn"), - Name: values.GetAttributeValue("displayname"), + Id: values.GetAttributeValue(config.UserNameAttr), + Displayname: values.GetAttributeValue("displayname"), Email: values.GetAttributeValue("email"), Description: values.GetAttributeValue("description"), DN: values.DN, @@ -80,13 +81,7 @@ func handleSearch(w http.ResponseWriter, r *http.Request) { } if result.Search == nil { result = Results{ - Search: append(result.Search, SearchResult{ - Identifiant: "", - Name: "", - Email: "", - Description: "", - DN: "", - }), + Search: append(result.Search, SearchResult{}), } } |