You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/oauth/oauth_resource.go

23 lines
449 B

package oauth
import (
"errors"
"strconv"
)
func GetUsername(datamap map[string]any, userIdentifier string) (string, error) {
username, ok := datamap[userIdentifier].(string)
if ok && username != "" {
return username, nil
}
if !ok {
username, ok := datamap[userIdentifier].(float64)
if ok && username != 0 {
return strconv.Itoa(int(username)), nil
}
}
return "", errors.New("failed to extract username from oauth resource")
}