mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 20:23:32 +08:00
feature (admin): admin console
This commit is contained in:
@ -9,26 +9,28 @@ import (
|
||||
|
||||
func NewBackend(ctx *App, conn map[string]string) (IBackend, error) {
|
||||
isAllowed := func() bool {
|
||||
ret := false
|
||||
var conns [] struct {
|
||||
Type string `json:"type"`
|
||||
Hostname string `json:"hostname"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
ctx.Config.Get("connections").Scan(&conns)
|
||||
for i := range conns {
|
||||
if conns[i].Type == conn["type"] {
|
||||
if conns[i].Hostname != "" && conns[i].Hostname != conn["hostname"] {
|
||||
continue
|
||||
} else if conns[i].Path != "" && conns[i].Path != conn["path"] {
|
||||
continue
|
||||
} else {
|
||||
ret = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
return true
|
||||
// ret := false
|
||||
// var conns [] struct {
|
||||
// Type string `json:"type"`
|
||||
// Hostname string `json:"hostname"`
|
||||
// Path string `json:"path"`
|
||||
// }
|
||||
// Config.Get("connections").Interface()
|
||||
// Config.Get("connections").Scan(&conns)
|
||||
// for i := range conns {
|
||||
// if conns[i].Type == conn["type"] {
|
||||
// if conns[i].Hostname != "" && conns[i].Hostname != conn["hostname"] {
|
||||
// continue
|
||||
// } else if conns[i].Path != "" && conns[i].Path != conn["path"] {
|
||||
// continue
|
||||
// } else {
|
||||
// ret = true
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return ret
|
||||
}()
|
||||
|
||||
if isAllowed == false {
|
||||
@ -57,6 +59,9 @@ func MapStringInterfaceToMapStringString(m map[string]interface{}) map[string]st
|
||||
res := make(map[string]string)
|
||||
for key, value := range m {
|
||||
res[key] = fmt.Sprintf("%v", value)
|
||||
if res[key] == "<nil>" {
|
||||
res[key] = ""
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user