pass a struct with the info

Former-commit-id: 6f9843613e6abfe0b19e6e43f9299afb98645477 [formerly 805fa39b073401c946b559e0e967fdc553f16295] [formerly f9e2de337abc0cbeb5ccdb8b6962871b0bd3ee0e [formerly 1d26b8e95e73a94ba92673861c4e83dfded0d92e]]
Former-commit-id: 259a1ba8cdc71e7d32add58f9487e5827aa6685e [formerly 161a1a49bc1158f11f07fc9ff638506dafb6c918]
Former-commit-id: 67fe1fef4602baf4ddae40b28e65ac9a2a42ca9d
This commit is contained in:
Henrique Dias
2017-06-27 09:57:11 +01:00
parent a3941facd9
commit f2b492e0ce
12 changed files with 79 additions and 70 deletions

View File

@@ -43,7 +43,7 @@ func parseSearch(value string) *searchOptions {
}
// search searches for a file or directory.
func search(w http.ResponseWriter, r *http.Request, m *FileManager, u *User) (int, error) {
func search(ctx *requestContext, w http.ResponseWriter, r *http.Request) (int, error) {
// Upgrades the connection to a websocket and checks for errors.
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
@@ -71,10 +71,10 @@ func search(w http.ResponseWriter, r *http.Request, m *FileManager, u *User) (in
}
search = parseSearch(value)
scope := strings.Replace(r.URL.Path, m.BaseURL, "", 1)
scope := strings.Replace(r.URL.Path, ctx.FileManager.BaseURL, "", 1)
scope = strings.TrimPrefix(scope, "/")
scope = "/" + scope
scope = u.scope + scope
scope = ctx.User.scope + scope
scope = strings.Replace(scope, "\\", "/", -1)
scope = filepath.Clean(scope)
@@ -92,7 +92,7 @@ func search(w http.ResponseWriter, r *http.Request, m *FileManager, u *User) (in
}
if strings.Contains(path, term) {
if !u.Allowed(path) {
if !ctx.User.Allowed(path) {
return nil
}