refactor: auth bearer check

This commit is contained in:
Michael Geers 2024-04-18 08:19:38 +02:00
parent 54c7440769
commit 708320d71f

View file

@ -58,9 +58,8 @@ func updatePasswordHandler(auth auth.Auth) http.HandlerFunc {
func jwtFromRequest(r *http.Request) string {
// read from header
authHeader := r.Header.Get("Authorization")
splitToken := strings.Split(authHeader, "Bearer ")
if len(splitToken) == 2 {
return splitToken[1]
if token, ok := strings.CutPrefix(authHeader, "Bearer "); ok {
return token
}
// read from cookie