File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,11 +14,5 @@ pub fn extract_token_from_header(req: &ServiceRequest) -> Option<String> {
1414 req. headers ( )
1515 . get ( "Authorization" )
1616 . and_then ( |h| h. to_str ( ) . ok ( ) )
17- . and_then ( |h| {
18- if h. starts_with ( "Bearer " ) {
19- Some ( h[ 7 ..] . to_string ( ) )
20- } else {
21- None
22- }
23- } )
17+ . and_then ( |h| h. strip_prefix ( "Bearer " ) . map ( |s| s. to_string ( ) ) )
2418}
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ impl LockoutService {
121121 . set_ex (
122122 & lockout_key,
123123 locked_until. to_string ( ) ,
124- self . lockout_duration as u64 ,
124+ self . lockout_duration ,
125125 )
126126 . await ?;
127127
Original file line number Diff line number Diff line change @@ -474,25 +474,13 @@ mod tests {
474474
475475 #[ test]
476476 fn test_backup_code_count_is_reasonable ( ) {
477- assert ! (
478- BACKUP_CODE_COUNT >= 5 ,
479- "Should have at least 5 backup codes"
480- ) ;
481- assert ! (
482- BACKUP_CODE_COUNT <= 20 ,
483- "Should have at most 20 backup codes"
484- ) ;
477+ const _: ( ) = assert ! ( BACKUP_CODE_COUNT >= 5 , "Should have at least 5 backup codes" ) ;
478+ const _: ( ) = assert ! ( BACKUP_CODE_COUNT <= 20 , "Should have at most 20 backup codes" ) ;
485479 }
486480
487481 #[ test]
488482 fn test_backup_code_length_is_reasonable ( ) {
489- assert ! (
490- BACKUP_CODE_LENGTH >= 6 ,
491- "Backup codes should be at least 6 chars"
492- ) ;
493- assert ! (
494- BACKUP_CODE_LENGTH <= 16 ,
495- "Backup codes should be at most 16 chars"
496- ) ;
483+ const _: ( ) = assert ! ( BACKUP_CODE_LENGTH >= 6 , "Backup codes should be at least 6 chars" ) ;
484+ const _: ( ) = assert ! ( BACKUP_CODE_LENGTH <= 16 , "Backup codes should be at most 16 chars" ) ;
497485 }
498486}
You can’t perform that action at this time.
0 commit comments