File tree Expand file tree Collapse file tree
SkredvarselGarminWeb/SkredvarselGarminWeb/Configuration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using System . Text . RegularExpressions ;
44using Microsoft . AspNetCore . Authentication ;
55using Microsoft . Extensions . Options ;
6+ using Microsoft . Extensions . Primitives ;
67using Microsoft . Net . Http . Headers ;
78using SkredvarselGarminWeb . Services ;
89
@@ -19,12 +20,12 @@ public GarminAuthenticationHandler(
1920
2021 protected override Task < AuthenticateResult > HandleAuthenticateAsync ( )
2122 {
22- if ( ! Request . Headers . ContainsKey ( HeaderNames . Authorization ) )
23+ if ( ! Request . Headers . TryGetValue ( HeaderNames . Authorization , out StringValues value ) )
2324 {
2425 return Task . FromResult ( AuthenticateResult . Fail ( "Header Not Found." ) ) ;
2526 }
2627
27- var header = Request . Headers [ HeaderNames . Authorization ] . ToString ( ) ;
28+ var header = value . ToString ( ) ;
2829 var tokenMatch = GarminAuthenticationHeader ( ) . Match ( header ) ;
2930
3031 if ( tokenMatch . Success )
@@ -44,7 +45,7 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
4445 }
4546 }
4647
47- return Task . FromResult ( AuthenticateResult . Fail ( "Did not find active agreement for watch." ) ) ;
48+ return Task . FromResult ( AuthenticateResult . Fail ( $ "Did not find active agreement for watch { header } .") ) ;
4849 }
4950
5051 [ GeneratedRegex ( "Garmin (?<token>.*)" ) ]
You can’t perform that action at this time.
0 commit comments