mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 07:11:15 +00:00
Improve admin privilege handling for OAuth. Update documentation.
This commit is contained in:
@@ -79,6 +79,27 @@ func MapDefaultString(m map[string]interface{}, key string, dflt string) string
|
||||
}
|
||||
}
|
||||
|
||||
// MapDefaultStringSlice returns the string slice value for the given key or a default value
|
||||
func MapDefaultStringSlice(m map[string]interface{}, key string, dflt []string) []string {
|
||||
if m == nil {
|
||||
return dflt
|
||||
}
|
||||
if tmp, ok := m[key]; !ok {
|
||||
return dflt
|
||||
} else {
|
||||
switch v := tmp.(type) {
|
||||
case []string:
|
||||
return v
|
||||
case string:
|
||||
return []string{v}
|
||||
case nil:
|
||||
return dflt
|
||||
default:
|
||||
return []string{fmt.Sprintf("%v", v)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UniqueStringSlice removes duplicates in the given string slice
|
||||
func UniqueStringSlice(slice []string) []string {
|
||||
keys := make(map[string]struct{})
|
||||
|
Reference in New Issue
Block a user