func checkTokenUsername(r *http.Request, tokenizer Tokenizer) error {
	authorization := r.Header.Get("Authorization")
	if len(authorization) < 7 || authorization[:7] != "Bearer " {
		return fmt.Errorf("invalid authorization header: %v", authorization)
	}
	tokenString := authorization[7:]
	tokenUsername, err := tokenizer.ReadUsername(tokenString)
	if err != nil {
		return err
	}
	formUsername := r.FormValue("username")
	if tokenUsername != formUsername {
		return fmt.Errorf("username not same as token username")
	}
	return nil
}
// checkTokenUsername ensures the username in the authorization header matches that in the username form value.
checkTokenUsername ensures the username in the authorization header matches that in the username form value.
// checkTokenUsername ensures the username in the authorization header matches that in the username form value .
func checkTokenUsername(r *http.Request, tokenizer Tokenizer) error {
	authorization := r.Header.Get("Authorization")
	if len(authorization) < 7 || authorization[:7] != "Bearer " {
		return fmt.Errorf("invalid authorization header: %v", authorization)
	}
	tokenString := authorization[7:]
	tokenUsername, err := tokenizer.ReadUsername(tokenString)
	if err != nil {
		return err
	}
	formUsername := r.FormValue("username")
	if tokenUsername != formUsername {
		return fmt.Errorf("username not same as token username")
	}
	return nil
}
func checkTokenUsername ( r * http . Request , tokenizer Tokenizer ) error { authorization := r . Header . Get ( " " ) if len ( authorization ) < 7 || authorization [ : 7 ] != " " { return fmt . Errorf ( " " , authorization ) } tokenString := authorization [ 7 : ] tokenUsername , err := tokenizer . ReadUsername ( tokenString ) if err != nil { return err } formUsername := r . FormValue ( " " ) if tokenUsername != formUsername { return fmt . Errorf ( " " ) } return nil }
checkTokenUsername ensures the username in the authorization header matches that in the username form value.
checkTokenUsername ensures the username in the authorization header matches that in the username form value .