File tree Expand file tree Collapse file tree 4 files changed +20
-15
lines changed
packages/dashboard-app/src/pages/settings Expand file tree Collapse file tree 4 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,7 @@ use aws_smithy_runtime_api::client::identity::{
4141} ;
4242use aws_smithy_types:: error:: display:: DisplayErrorContext ;
4343use aws_types:: region:: Region ;
44- use eyre:: {
45- Result ,
46- eyre,
47- } ;
44+ use eyre:: Result ;
4845use time:: OffsetDateTime ;
4946use tracing:: {
5047 debug,
@@ -606,7 +603,7 @@ pub async fn is_idc_user(database: &Database) -> Result<bool> {
606603 if let Ok ( Some ( token) ) = BuilderIdToken :: load ( database) . await {
607604 Ok ( token. token_type ( ) == TokenType :: IamIdentityCenter )
608605 } else {
609- Err ( eyre ! ( "No auth token found - is the user signed in?" ) )
606+ Ok ( false )
610607 }
611608}
612609
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ use crate::auth::builder_id::{
3333 BuilderIdToken ,
3434 PollCreateToken ,
3535 TokenType ,
36+ is_idc_user,
3637 poll_create_token,
3738 start_device_authorization,
3839} ;
@@ -338,10 +339,8 @@ pub enum LicenseType {
338339}
339340
340341pub async fn profile ( os : & mut Os ) -> Result < ExitCode > {
341- if let Ok ( Some ( token) ) = BuilderIdToken :: load ( & os. database ) . await {
342- if matches ! ( token. token_type( ) , TokenType :: BuilderId ) {
343- bail ! ( "This command is only available for Pro users" ) ;
344- }
342+ if !is_idc_user ( & os. database ) . await ? {
343+ bail ! ( "This command is only available for IAM Identity Center users" ) ;
345344 }
346345
347346 select_profile_interactive ( os, false ) . await ?;
Original file line number Diff line number Diff line change @@ -229,13 +229,18 @@ impl RootUserSubcommand {
229229 Self :: Profile => {
230230 assert_logged_in ( ) . await ?;
231231
232- if let Ok ( Some ( token) ) = fig_auth:: builder_id_token ( ) . await {
233- if matches ! ( token. token_type( ) , TokenType :: IamIdentityCenter ) {
234- select_profile_interactive ( false ) . await ?;
235- }
232+ let is_idc = fig_auth:: builder_id_token ( )
233+ . await
234+ . ok ( )
235+ . flatten ( )
236+ . is_some_and ( |token| matches ! ( token. token_type( ) , TokenType :: IamIdentityCenter ) ) ;
237+
238+ if !is_idc {
239+ bail ! ( "This command is only available for IAM Identity Center users" ) ;
236240 }
237241
238- bail ! ( "This command is only available for IAM Identity Center users" ) ;
242+ select_profile_interactive ( false ) . await ?;
243+ Ok ( ExitCode :: SUCCESS )
239244 } ,
240245 }
241246 }
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ export default function Page() {
2323 const [ profiles , setProfiles ] = useState < Profile [ ] | undefined > ( undefined ) ;
2424
2525 useEffect ( ( ) => {
26+ if ( auth . authKind !== "IamIdentityCenter" ) {
27+ return ;
28+ }
29+
2630 Profile . listAvailableProfiles ( )
2731 . then ( async ( res ) => {
2832 setProfiles (
@@ -35,7 +39,7 @@ export default function Page() {
3539 . catch ( ( err ) => {
3640 console . error ( err ) ;
3741 } ) ;
38- } , [ ] ) ;
42+ } , [ auth . authKind ] ) ;
3943
4044 useEffect ( ( ) => {
4145 State . get ( "api.codewhisperer.profile" ) . then ( ( profile ) => {
You can’t perform that action at this time.
0 commit comments