show everyone in the directory page by default
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
darkgallium 2021-08-18 12:44:44 +02:00
parent a187ae72cb
commit 59c29e9c76
3 changed files with 22 additions and 18 deletions

View file

@ -43,7 +43,7 @@ func handleDirectorySearch(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(1024)
input := strings.TrimSpace(strings.Join(r.Form["query"], ""))
if r.Method != "POST" || input == "" {
if r.Method != "POST" {
http.Error(w, "Invalid request", http.StatusBadRequest)
return
}
@ -79,7 +79,8 @@ func handleDirectorySearch(w http.ResponseWriter, r *http.Request) {
results := []SearchResult{}
for _, values := range sr.Entries {
if ContainsI(values.GetAttributeValue(config.UserNameAttr), input) ||
if input == "" ||
ContainsI(values.GetAttributeValue(config.UserNameAttr), input) ||
ContainsI(values.GetAttributeValue("displayname"), input) ||
ContainsI(values.GetAttributeValue("mail"), input) {
results = append(results, SearchResult{

View file

@ -2,7 +2,6 @@ var last_id = 0;
function searchDirectory() {
var input = document.getElementById("search").value;
if(input){
last_id++;
var request_id = last_id;
@ -20,5 +19,4 @@ function searchDirectory() {
};
xhttp.open("POST", "/directory/search", true);
xhttp.send(data);
}
}

View file

@ -19,5 +19,10 @@
<div id="search-results"></div>
<script src="/static/javascript/search.js"></script>
<script>
window.addEventListener("load", function(event) {
searchDirectory();
});
</script>
{{end}}