Set empty role ids array

This commit is contained in:
Benedikt Kulmann
2020-12-15 00:25:01 +01:00
parent df391d5966
commit 633391e30d
+3 -1
View File
@@ -2,6 +2,7 @@ package middleware
import (
"context"
"encoding/json"
"net/http"
"github.com/cs3org/reva/pkg/token/manager/jwt"
@@ -46,7 +47,8 @@ func ExtractAccountUUID(opts ...account.Option) func(http.Handler) http.Handler
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
token := r.Header.Get("x-access-token")
if len(token) == 0 {
ctx := metadata.Set(r.Context(), RoleIDs, "")
roleIDsJSON, _ := json.Marshal([]string{})
ctx := metadata.Set(r.Context(), RoleIDs, string(roleIDsJSON))
next.ServeHTTP(w, r.WithContext(ctx))
return
}