@@ -476,12 +476,15 @@ fn request_device_authorization(
476476 } ;
477477
478478 Ok ( DeviceAuthResponse {
479- device_code : field ( "device_code" ) ?,
480- user_code : field ( "user_code" ) ?,
481- verification_uri : field ( "verification_uri" ) ?,
479+ device_code : field ( "device_code" ) ?,
480+ user_code : field ( "user_code" ) ?,
481+ verification_uri : field ( "verification_uri" ) ?,
482482 verification_uri_complete : field ( "verification_uri_complete" ) ?,
483- expires_in : inner. get ( "expires_in" ) . and_then ( |v| v. as_u64 ( ) ) . unwrap_or ( 300 ) ,
484- interval : inner. get ( "interval" ) . and_then ( |v| v. as_u64 ( ) ) . unwrap_or ( 5 ) ,
483+ expires_in : inner
484+ . get ( "expires_in" )
485+ . and_then ( |v| v. as_u64 ( ) )
486+ . unwrap_or ( 300 ) ,
487+ interval : inner. get ( "interval" ) . and_then ( |v| v. as_u64 ( ) ) . unwrap_or ( 5 ) ,
485488 } )
486489}
487490
@@ -557,9 +560,7 @@ fn poll_device_token(
557560 "Session expired. Please run `stacker login` again." . to_string ( ) ,
558561 ) )
559562 }
560- Some ( other) => {
561- return Err ( CliError :: AuthFailed ( format ! ( "Auth error: {other}" ) ) )
562- }
563+ Some ( other) => return Err ( CliError :: AuthFailed ( format ! ( "Auth error: {other}" ) ) ) ,
563564 None => { } // unexpected non-200 without error field — keep polling
564565 }
565566 }
@@ -586,7 +587,8 @@ pub fn fetch_user_email(auth_url: &str, access_token: &str) -> Result<Option<Str
586587 }
587588
588589 let data: serde_json:: Value = resp. json ( ) . unwrap_or ( serde_json:: Value :: Null ) ;
589- let email = data. get ( "email" )
590+ let email = data
591+ . get ( "email" )
590592 . or_else ( || data. get ( "user" ) . and_then ( |u| u. get ( "email" ) ) )
591593 . and_then ( |v| v. as_str ( ) )
592594 . map ( |s| s. to_string ( ) ) ;
@@ -616,11 +618,23 @@ pub fn browser_login<S: CredentialStore>(
616618
617619 let opened = {
618620 #[ cfg( target_os = "macos" ) ]
619- { std:: process:: Command :: new ( "open" ) . arg ( & device_auth. verification_uri_complete ) . status ( ) . is_ok ( ) }
621+ {
622+ std:: process:: Command :: new ( "open" )
623+ . arg ( & device_auth. verification_uri_complete )
624+ . status ( )
625+ . is_ok ( )
626+ }
620627 #[ cfg( target_os = "linux" ) ]
621- { std:: process:: Command :: new ( "xdg-open" ) . arg ( & device_auth. verification_uri_complete ) . status ( ) . is_ok ( ) }
628+ {
629+ std:: process:: Command :: new ( "xdg-open" )
630+ . arg ( & device_auth. verification_uri_complete )
631+ . status ( )
632+ . is_ok ( )
633+ }
622634 #[ cfg( not( any( target_os = "macos" , target_os = "linux" ) ) ) ]
623- { false }
635+ {
636+ false
637+ }
624638 } ;
625639 if opened {
626640 eprintln ! ( " (Browser opened automatically)" ) ;
@@ -647,7 +661,9 @@ pub fn browser_login<S: CredentialStore>(
647661 token_type : "Bearer" . to_string ( ) ,
648662 expires_at,
649663 email,
650- server_url : Some ( crate :: cli:: install_runner:: normalize_stacker_server_url ( server_url) ) ,
664+ server_url : Some ( crate :: cli:: install_runner:: normalize_stacker_server_url (
665+ server_url,
666+ ) ) ,
651667 org : org. map ( |s| s. to_string ( ) ) ,
652668 domain : domain. map ( |s| s. to_string ( ) ) ,
653669 } ;
0 commit comments