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

fix: sasjs server type - request and job execution auth fix

This commit is contained in:
2022-04-26 16:18:36 +02:00
parent 4ebf949912
commit 936e4f8c0a
3 changed files with 36 additions and 22 deletions

View File

@@ -21,6 +21,7 @@ import {
} from '../utils'
import { BaseJobExecutor } from './JobExecutor'
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
import { Server } from 'https'
export interface WaitingRequstPromise {
promise: Promise<any> | null
@@ -220,25 +221,36 @@ export class WebJobExecutor extends BaseJobExecutor {
}
if (e instanceof LoginRequiredError) {
this.appendWaitingRequest(() => {
return this.execute(
sasJob,
data,
config,
loginRequiredCallback,
authConfig,
extraResponseAttributes
).then(
(res: any) => {
resolve(res)
},
(err: any) => {
reject(err)
}
)
})
switch (this.serverType) {
case ServerType.Sasjs:
reject(
new ErrorResponse(
'Request is not authenticated. Make sure .env file exists with valid credentials.',
e
)
)
break
default:
this.appendWaitingRequest(() => {
return this.execute(
sasJob,
data,
config,
loginRequiredCallback,
authConfig,
extraResponseAttributes
).then(
(res: any) => {
resolve(res)
},
(err: any) => {
reject(err)
}
)
})
await loginCallback()
await loginCallback()
}
} else {
reject(new ErrorResponse(e?.message, e))
}