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

chore(git): Merge branch 'master' into issue-408

This commit is contained in:
2021-06-10 15:06:10 +02:00
4 changed files with 267 additions and 599 deletions

792
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2005,9 +2005,9 @@
},
"@sasjs/adapter": {
"version": "file:../build/sasjs-adapter-5.0.0.tgz",
"integrity": "sha512-1GSSoHt6MumQQ0Y080PA4PCHJ1vRpkx+Syi3Io6poQzOGrYM6Z4lQFilXsdoogPdcfgO5po9OX1dr7AM0hKugQ==",
"integrity": "sha512-nP9O64IslMipxSKAG8PV/X2fRr+0E4/RqwD8jXP2bqZ/QraiKZG0bQPC5hSKqEp7bho8+XpZ4HaXW3Vr9kEZ8Q==",
"requires": {
"@sasjs/utils": "^2.17.1",
"@sasjs/utils": "^2.14.0",
"axios": "^0.21.1",
"axios-cookiejar-support": "^1.0.1",
"form-data": "^4.0.0",
@@ -2064,9 +2064,9 @@
}
},
"@sasjs/utils": {
"version": "2.18.0",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.18.0.tgz",
"integrity": "sha512-6VTbRP1KU0gGi1mSIHl+XyL9Vqk8rBW7a7VQOF6vzD+AVgfgYd0t76djAUCcA7Dos8NJXAoDUuah+iNvXJY+cw==",
"version": "2.15.5",
"resolved": "https://registry.npmjs.org/@sasjs/utils/-/utils-2.15.5.tgz",
"integrity": "sha512-5HSWX5fy8D0Zy+Le+LgeRZG4vb5quLqhNiHw3dl0MS2hpsWACSRKia060jZk9LNHayKwBuusjlz5Ba0SyyaiEQ==",
"requires": {
"@types/prompts": "^2.0.11",
"chalk": "^4.1.1",

View File

@@ -13,14 +13,19 @@ const App = (): ReactElement<{}> => {
useEffect(() => {
if (adapter) {
setTestSuites([
const testSuites = [
basicTests(adapter, config.userName, config.password),
sendArrTests(adapter),
sendObjTests(adapter),
specialCaseTests(adapter),
sasjsRequestTests(adapter),
computeTests(adapter)
])
sasjsRequestTests(adapter)
]
if (adapter.getSasjsConfig().serverType === 'SASVIYA') {
testSuites.push(computeTests(adapter))
}
setTestSuites(testSuites)
}
}, [adapter, config])

View File

@@ -35,6 +35,7 @@ export class AuthManager {
this.userName = loginParams.username
const { isLoggedIn, loginForm } = await this.checkSession()
if (isLoggedIn) {
await this.loginCallback()
@@ -44,6 +45,35 @@ export class AuthManager {
}
}
let loginResponse = await this.sendLoginRequest(loginForm, loginParams)
let loggedIn = isLogInSuccess(loginResponse)
if (!loggedIn) {
if (isCredentialsVerifyError(loginResponse)) {
const newLoginForm = await this.getLoginForm(loginResponse)
loginResponse = await this.sendLoginRequest(newLoginForm, loginParams)
}
const currentSession = await this.checkSession()
loggedIn = currentSession.isLoggedIn
}
if (loggedIn) {
this.loginCallback()
}
return {
isLoggedIn: !!loggedIn,
userName: this.userName
}
}
private async sendLoginRequest(
loginForm: { [key: string]: any },
loginParams: { [key: string]: any }
) {
for (const key in loginForm) {
loginParams[key] = loginForm[key]
}
@@ -60,21 +90,7 @@ export class AuthManager {
}
)
let loggedIn = isLogInSuccess(loginResponse)
if (!loggedIn) {
const currentSession = await this.checkSession()
loggedIn = currentSession.isLoggedIn
}
if (loggedIn) {
this.loginCallback()
}
return {
isLoggedIn: !!loggedIn,
userName: this.userName
}
return loginResponse
}
/**
@@ -168,5 +184,10 @@ export class AuthManager {
}
}
const isCredentialsVerifyError = (response: string): boolean =>
/An error occurred while the system was verifying your credentials. Please enter your credentials again./gm.test(
response
)
const isLogInSuccess = (response: string): boolean =>
/You have signed in/gm.test(response)