diff --git a/src/SASjs.ts b/src/SASjs.ts
index edb0232..1d0bf4d 100644
--- a/src/SASjs.ts
+++ b/src/SASjs.ts
@@ -411,6 +411,29 @@ export default class SASjs {
}
}
+ private async getLoginForm(response: any) {
+ const pattern: RegExp = /
/
+ const matches = pattern.exec(response)
+ const formInputs: any = {}
+
+ if (matches && matches.length) {
+ this.setLoginUrl(matches)
+ const inputs = response.match(/]*>/g)
+
+ if (inputs) {
+ inputs.forEach((inputStr: string) => {
+ const valueMatch = inputStr.match(/name="([^"]*)"\svalue="([^"]*)/)
+
+ if (valueMatch && valueMatch.length) {
+ formInputs[valueMatch[1]] = valueMatch[2]
+ }
+ })
+ }
+ }
+
+ return Object.keys(formInputs).length ? formInputs : null
+ }
+
/**
* Checks whether a session is active, or login is required.
* @returns - a promise which resolves with an object containing two values - a boolean `isLoggedIn`, and a string `userName`.
@@ -419,10 +442,16 @@ export default class SASjs {
const loginResponse = await fetch(this.loginUrl.replace('.do', ''))
const responseText = await loginResponse.text()
const isLoggedIn = //
- const response = await fetch(this.loginUrl).then((r) => r.text())
- const matches = pattern.exec(response)
- const formInputs: any = {}
- if (matches && matches.length) {
- this.setLoginUrl(matches)
- const inputs = response.match(/]*>/g)
- if (inputs) {
- inputs.forEach((inputStr: string) => {
- const valueMatch = inputStr.match(/name="([^"]*)"\svalue="([^"]*)/)
- if (valueMatch && valueMatch.length) {
- formInputs[valueMatch[1]] = valueMatch[2]
- }
- })
- }
- }
- return Object.keys(formInputs).length ? formInputs : null
- }
-
private async createFoldersAndServices(
parentFolder: string,
membersJson: any[],