1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-03 10:40:06 +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() { public async checkSession() {
const { result: loginResponse } = await this.requestClient.get<string>( const { result: loginResponse } = await this.requestClient.get<string>(
this.loginUrl.replace('.do', ''), `${this.serverUrl}/${this.serverType === 'SASVIYA' ? 'SASJobExecution' : 'SASStoredProcess'}`,
undefined, undefined,
'text/plain' 'text/plain'
) ).catch((err: any) => {
const responseText = loginResponse return {result: 'authErr'}
const isLoggedIn = /<button.+onClick.+logout/gm.test(responseText) })
let loginForm: any = null
const isLoggedIn = loginResponse !== 'authErr'
let loginForm = null
if (!isLoggedIn) { 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({ return Promise.resolve({