mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 08:40:01 +00:00
23 lines
469 B
Go
23 lines
469 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func getAuthorizationFromRequest(r *http.Request) (string, error) {
|
|
token := r.Header.Get("Authorization")
|
|
if token == "" {
|
|
return "", fmt.Errorf("no authorization provided")
|
|
}
|
|
|
|
_, user, _, _, err := editorTokenService.ValidateLoginToken(token) //nolint:dogsled // Required at other places
|
|
|
|
if user == "" {
|
|
user = "API-User"
|
|
}
|
|
|
|
return user, errors.Wrap(err, "getting authorized user")
|
|
}
|