fix generic plugin error message.

This commit is contained in:
Miroslav Šedivý 2022-10-25 22:46:21 +02:00
parent 6067367acd
commit d894e888b8

View File

@ -80,13 +80,17 @@ func PluginsGenericOnly[V comparable](key string, exp V) func(w http.ResponseWri
plugins := session.Profile().Plugins plugins := session.Profile().Plugins
if plugins[key] == nil {
return nil, utils.HttpForbidden(fmt.Sprintf("missing plugin permission: %s=%T", key, exp))
}
val, ok := plugins[key].(V) val, ok := plugins[key].(V)
if !ok { if !ok {
return nil, utils.HttpForbidden(fmt.Sprintf("%s is %T, but expected %T", key, plugins[key], exp)) return nil, utils.HttpForbidden(fmt.Sprintf("invalid plugin permission type: %s=%T expected %T", key, plugins[key], exp))
} }
if val != exp { if val != exp {
return nil, utils.HttpForbidden(fmt.Sprintf("%s is set to %v, but expected %v", key, val, exp)) return nil, utils.HttpForbidden(fmt.Sprintf("wrong plugin permission value for %s=%T", key, exp))
} }
return nil, nil return nil, nil