@@ -592,13 +592,12 @@ function login(command: cli.ILoginCommand): Promise<void> {
592
592
if ( command . accessKey ) {
593
593
var proxy = getProxy ( command . proxy , command . noProxy ) ;
594
594
sdk = getSdk ( command . accessKey , CLI_HEADERS , command . serverUrl , proxy ) ;
595
- return sdk . isAuthenticated ( )
596
- . then ( ( isAuthenticated : boolean ) : void => {
597
- if ( isAuthenticated ) {
598
- serializeConnectionInfo ( command . accessKey , /*preserveAccessKeyOnLogout*/ true , command . serverUrl , command . proxy , command . noProxy ) ;
599
- } else {
600
- throw new Error ( "Invalid access key." ) ;
601
- }
595
+ return sdk . ensureAuthenticated ( )
596
+ . catch ( ( err : CodePushError ) => {
597
+ throw new Error ( "Invalid access key." ) ;
598
+ } )
599
+ . then ( ( ) : void => {
600
+ serializeConnectionInfo ( command . accessKey , /*preserveAccessKeyOnLogout*/ true , command . serverUrl , command . proxy , command . noProxy ) ;
602
601
} ) ;
603
602
} else {
604
603
return loginWithExternalAuthentication ( "login" , command . serverUrl , command . proxy , command . noProxy ) ;
@@ -618,13 +617,12 @@ function loginWithExternalAuthentication(action: string, serverUrl?: string, pro
618
617
619
618
sdk = getSdk ( accessKey , CLI_HEADERS , serverUrl , getProxy ( proxy , noProxy ) ) ;
620
619
621
- return sdk . isAuthenticated ( )
622
- . then ( ( isAuthenticated : boolean ) : void => {
623
- if ( isAuthenticated ) {
624
- serializeConnectionInfo ( accessKey , /*preserveAccessKeyOnLogout*/ false , serverUrl , proxy , noProxy ) ;
625
- } else {
626
- throw new Error ( "Invalid access key." ) ;
627
- }
620
+ return sdk . ensureAuthenticated ( )
621
+ . catch ( ( err : CodePushError ) => {
622
+ throw new Error ( "Invalid access key." ) ;
623
+ } )
624
+ . then ( ( ) : void => {
625
+ serializeConnectionInfo ( accessKey , /*preserveAccessKeyOnLogout*/ false , serverUrl , proxy , noProxy ) ;
628
626
} ) ;
629
627
} ) ;
630
628
}
@@ -1172,7 +1170,10 @@ export var release = (command: cli.IReleaseCommand): Promise<void> => {
1172
1170
1173
1171
return getPackageFilePromise
1174
1172
. then ( ( file : IPackageFile ) : Promise < void > => {
1175
- return sdk . release ( command . appName , command . deploymentName , file . path , command . appStoreVersion , updateMetadata , uploadProgress )
1173
+ return sdk . ensureAuthenticated ( )
1174
+ . then ( ( isAuth : boolean ) : Promise < void > => {
1175
+ return sdk . release ( command . appName , command . deploymentName , file . path , command . appStoreVersion , updateMetadata , uploadProgress ) ;
1176
+ } )
1176
1177
. then ( ( ) : void => {
1177
1178
log ( "Successfully released an update containing the \"" + command . package + "\" " + ( isSingleFilePackage ? "file" : "directory" ) + " to the \"" + command . deploymentName + "\" deployment of the \"" + command . appName + "\" app." ) ;
1178
1179
} )
0 commit comments