From ff85f0b11b59099f6374ee8433a473f3215d4899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 14 May 2022 00:30:58 +0200 Subject: [PATCH] PluginsGenericOnly debug types. --- pkg/auth/auth.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 43126ae5..12c24155 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -71,7 +71,7 @@ func CanAccessClipboardOnly(w http.ResponseWriter, r *http.Request) (context.Con return nil, nil } -func PluginsGenericOnly[V comparable](key string, value V) func(w http.ResponseWriter, r *http.Request) (context.Context, error) { +func PluginsGenericOnly[V comparable](key string, exp V) func(w http.ResponseWriter, r *http.Request) (context.Context, error) { return func(w http.ResponseWriter, r *http.Request) (context.Context, error) { session, ok := GetSession(r) if !ok { @@ -79,10 +79,16 @@ func PluginsGenericOnly[V comparable](key string, value V) func(w http.ResponseW } plugins := session.Profile().Plugins - if val, ok := plugins[key].(V); !ok || val != value { - return nil, utils.HttpForbidden(fmt.Sprintf("%s is set to %v; expected %v", key, value, val)) + + val, ok := plugins[key].(V) + if !ok { + return nil, utils.HttpForbidden(fmt.Sprintf("%s is %T, but expected %T", key, plugins[key], exp)) } - + + if val != exp { + return nil, utils.HttpForbidden(fmt.Sprintf("%s is set to %v, but expected %v", key, val, exp)) + } + return nil, nil } }