1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-10 17:04:36 +00:00

fix: login checkSession improved mechanism

This commit is contained in:
2021-03-28 18:40:04 +02:00
parent a023ffe850
commit 28370341d8
2 changed files with 64 additions and 17087 deletions

17128
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -83,16 +83,27 @@ export class AuthManager {
*/
public async checkSession() {
const { result: loginResponse } = await this.requestClient.get<string>(
this.loginUrl.replace('.do', ''),
`${this.serverUrl}/${this.serverType === 'SASVIYA' ? 'SASJobExecution' : 'SASStoredProcess'}`,
undefined,
'text/plain'
)
const responseText = loginResponse
const isLoggedIn = /<button.+onClick.+logout/gm.test(responseText)
let loginForm: any = null
).catch((err: any) => {
return {result: 'authErr'}
})
const isLoggedIn = loginResponse !== 'authErr'
let loginForm = null
if (!isLoggedIn) {
loginForm = await this.getLoginForm(responseText)
//We will logout to make sure cookies are removed and login form is presented
this.logOut()
const { result: formResponse } = await this.requestClient.get<string>(
this.loginUrl.replace('do', ''),
undefined,
'text/plain'
)
loginForm = await this.getLoginForm(formResponse)
}
return Promise.resolve({