twitch-bot/botEditor.go
Knut Ahlers 1a425416b8
Add channel editing interface
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-11-25 00:41:21 +01:00

25 lines
525 B
Go

package main
import (
"fmt"
"net/http"
"strings"
)
func getAuthorizationFromRequest(r *http.Request) (string, error) {
_, token, hadPrefix := strings.Cut(r.Header.Get("Authorization"), " ")
if !hadPrefix {
return "", fmt.Errorf("no authorization provided")
}
_, user, _, _, err := editorTokenService.ValidateLoginToken(token) //nolint:dogsled // Required at other places
if err != nil {
return "", fmt.Errorf("getting authorized user: %w", err)
}
if user == "" {
user = "API-User"
}
return user, nil
}