File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,19 @@ zitiFetch = async ( url, opts ) => {
621621
622622 if ( url . match ( regex ) ) { // the request is targeting the Ziti HTTP Agent
623623
624+ let updb = new ZitiUPDB ( ZitiUPDB . prototype ) ;
625+ await updb . init ( { ctx : ziti . _ctx , logger : ziti . _ctx . logger } ) ;
626+ let haveCreds = await updb . _haveCreds ( ) ;
627+ if ( ! haveCreds ) {
628+ await updb . awaitCredentialsAndAPISession ( ) ;
629+ } else {
630+ // Remain in this loop until the creds entered on login form are acceptable to the Ziti Controller
631+ let validCreds ;
632+ do {
633+ validCreds = await ziti . _ctx . ensureAPISession ( ) ;
634+ } while ( ! validCreds ) ;
635+ }
636+
624637 var newUrl = new URL ( url ) ;
625638 newUrl . hostname = zitiConfig . httpAgent . target . host ;
626639 newUrl . port = zitiConfig . httpAgent . target . port ;
Original file line number Diff line number Diff line change @@ -281,8 +281,7 @@ ZitiContext.prototype._awaitIdentityLoadCompleteFromServiceWorker = async functi
281281
282282 if ( ! isUndefined ( res . error ) ) {
283283 self . logger . error ( res . error . message ) ;
284- resolve ( false ) ;
285- return ;
284+ return resolve ( false ) ;
286285 }
287286
288287 self . _apiSession = res . data ;
@@ -293,7 +292,7 @@ ZitiContext.prototype._awaitIdentityLoadCompleteFromServiceWorker = async functi
293292
294293 await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_API_SESSION_TOKEN , self . _apiSession , new Date ( Date . parse ( self . _apiSession . expiresAt ) ) ) ;
295294
296- resolve ( true ) ;
295+ return resolve ( true ) ;
297296 } ) ;
298297}
299298
Original file line number Diff line number Diff line change @@ -171,6 +171,10 @@ ZitiUPDB.prototype.promptForCreds = async function() {
171171 expiry . setMinutes ( expiry . getMinutes ( ) + 5 ) ;
172172 await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_IDENTITY_USERNAME , self . _loginFormValues . username , expiry ) ;
173173 await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_IDENTITY_PASSWORD , self . _loginFormValues . password , expiry ) ;
174+
175+ // if we're restarting with updb, then purge any existing API session & cert
176+ await ls . removeItem ( zitiConstants . get ( ) . ZITI_API_SESSION_TOKEN ) ;
177+ await ls . removeItem ( zitiConstants . get ( ) . ZITI_CLIENT_CERT_PEM ) ;
174178 } ) ;
175179
176180 MicroModal . init ( {
You can’t perform that action at this time.
0 commit comments