1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-18 21:09:40 +02:00
portainer/api/oauth/oauth_resource.go

22 lines
449 B
Go

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")
}