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:
17128
package-lock.json
generated
17128
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user