diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index 2418d67..7d29cf9 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -124,7 +124,8 @@ export class AuthManager { if (!isLoggedIn) { //We will logout to make sure cookies are removed and login form is presented - this.logOut() + //Residue can happen in case of session expiration + await this.logOut() const { result: formResponse } = await this.requestClient.get( this.loginUrl.replace('.do', ''), diff --git a/src/job-execution/WebJobExecutor.ts b/src/job-execution/WebJobExecutor.ts index 560b1bf..d3b6faf 100644 --- a/src/job-execution/WebJobExecutor.ts +++ b/src/job-execution/WebJobExecutor.ts @@ -55,6 +55,15 @@ export class WebJobExecutor extends BaseJobExecutor { apiUrl += jobUri.length > 0 ? '&_job=' + jobUri : '' + if (jobUri.length > 0) { + apiUrl += '&_job=' + jobUri + /** + * Using both _job and _program parameters will cause a conflict in the JES web app, as it’s not clear whether or not the server should make the extra fetch for the job uri. + * To handle this, we add the extra underscore and recreate the _program variable in the SAS side of the SASjs adapter so it remains available for backend developers. + */ + apiUrl = apiUrl.replace('_program=', '__program=') + } + // if context name exists and is not blank string // then add _contextname variable in apiUrl apiUrl += @@ -122,8 +131,8 @@ export class WebJobExecutor extends BaseJobExecutor { this.appendRequest(res, sasJob, config.debug) resolve(res.result) } - getValidJson(res.result) this.appendRequest(res, sasJob, config.debug) + getValidJson(res.result as string) resolve(res.result) }) .catch(async (e: Error) => {