1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-17 09:00:06 +00:00

fix: web request and login

This commit is contained in:
2021-08-18 11:42:34 +02:00
parent dd2b3671fd
commit cd67fb38dc
2 changed files with 13 additions and 13 deletions

View File

@@ -124,7 +124,8 @@ export class AuthManager {
if (!isLoggedIn) { if (!isLoggedIn) {
//We will logout to make sure cookies are removed and login form is presented //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<string>( const { result: formResponse } = await this.requestClient.get<string>(
this.loginUrl.replace('.do', ''), this.loginUrl.replace('.do', ''),

View File

@@ -54,6 +54,15 @@ export class WebJobExecutor extends BaseJobExecutor {
apiUrl += jobUri.length > 0 ? '&_job=' + jobUri : '' 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 its 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 // if context name exists and is not blank string
// then add _contextname variable in apiUrl // then add _contextname variable in apiUrl
apiUrl += apiUrl +=
@@ -62,6 +71,7 @@ export class WebJobExecutor extends BaseJobExecutor {
: '' : ''
} }
let requestParams = { let requestParams = {
...this.getRequestParams(config) ...this.getRequestParams(config)
} }
@@ -112,20 +122,9 @@ export class WebJobExecutor extends BaseJobExecutor {
this.appendRequest(res, sasJob, config.debug) this.appendRequest(res, sasJob, config.debug)
resolve(jsonResponse) resolve(jsonResponse)
} }
if (this.serverType === ServerType.Sas9 && config.debug) {
const jsonResponse = parseWeboutResponse(res.result as string)
if (jsonResponse === '') {
throw new Error(
'Valid JSON could not be extracted from response.'
)
}
getValidJson(jsonResponse)
this.appendRequest(res, sasJob, config.debug)
resolve(res.result)
}
getValidJson(res.result as string)
this.appendRequest(res, sasJob, config.debug) this.appendRequest(res, sasJob, config.debug)
getValidJson(res.result as string)
resolve(res.result) resolve(res.result)
}) })
.catch(async (e: Error) => { .catch(async (e: Error) => {