File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,12 @@ impl<'a> UserAuthenticationExt for dyn Request + 'a {
42
42
user_id : token. user_id ,
43
43
token_id : Some ( token. id ) ,
44
44
} )
45
- // Convert a NotFound (or other database error) into Unauthorized
46
- . map_err ( |_ | Box :: new ( Unauthorized ) as Box < dyn AppError > )
45
+ . chain_error ( || internal ( "invalid token" ) )
46
+ . chain_error ( | | Box :: new ( Unauthorized ) as Box < dyn AppError > )
47
47
} else {
48
48
// Unable to authenticate the user
49
- Err ( Box :: new ( Unauthorized ) )
49
+ Err ( internal ( "no cookie session or auth header found" ) )
50
+ . chain_error ( || Box :: new ( Unauthorized ) as Box < dyn AppError > )
50
51
}
51
52
}
52
53
}
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ impl Handler for BlockTraffic {
47
47
. iter ( )
48
48
. any ( |value| self . blocked_values . iter ( ) . any ( |v| v == value) ) ;
49
49
if has_blocked_value {
50
+ let cause = format ! ( "blocked due to contents of header {}" , self . header_name) ;
51
+ super :: log_request:: add_custom_metadata ( req, "cause" , cause) ;
50
52
let body = format ! (
51
53
"We are unable to process your request at this time. \
52
54
This usually means that you are in violation of our crawler \
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ impl Handler for RequireUserAgent {
24
24
let has_user_agent = request_header ( req, "User-Agent" ) != "" ;
25
25
let is_download = req. path ( ) . ends_with ( "download" ) ;
26
26
if !has_user_agent && !is_download {
27
+ super :: log_request:: add_custom_metadata ( req, "cause" , "no user agent" ) ;
27
28
let body = format ! (
28
29
include_str!( "no_user_agent_message.txt" ) ,
29
30
request_header( req, "X-Request-Id" ) ,
You can’t perform that action at this time.
0 commit comments