diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index a061957..a8ad0a4 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -1,5 +1,6 @@ import { ServerType } from '@sasjs/utils/types' import { RequestClient } from '../request/RequestClient' +import { NotFoundError } from '../types/errors' import { LoginOptions, LoginResult, LoginResultInternal } from '../types/Login' import { serialize } from '../utils' import { extractUserLongNameSas9 } from '../utils/sas9/extractUserLongNameSas9' @@ -47,7 +48,8 @@ export class AuthManager { return { isLoggedIn: true, userName: currentSessionUserName, - userLongName: currentSessionUserLongName + userLongName: currentSessionUserLongName, + message: 'User is already Logged In!' } } @@ -116,7 +118,8 @@ export class AuthManager { return { isLoggedIn: true, userName: this.userName, - userLongName: this.userLongName + userLongName: this.userLongName, + message: 'User is already Logged In!' } } @@ -155,10 +158,12 @@ export class AuthManager { private async performCASSecurityCheck() { const casAuthenticationUrl = `${this.serverUrl}/SASStoredProcess/j_spring_cas_security_check` - await this.requestClient.get( - `/SASLogon/login?service=${casAuthenticationUrl}`, - undefined - ) + await this.requestClient + .get(`/SASLogon/login?service=${casAuthenticationUrl}`, undefined) + .catch((err) => { + // ignore if resource not found error + if (!(err instanceof NotFoundError)) throw err + }) } private async sendLoginRequest( @@ -312,12 +317,13 @@ export class AuthManager { } private getLoginForm(response: any) { - const pattern: RegExp = // + const pattern: RegExp = // const matches = pattern.exec(response) const formInputs: any = {} if (matches && matches.length) { this.setLoginUrl(matches) + response = response.replace(/]*>/g) if (inputs) { diff --git a/src/auth/isLoginRequired.ts b/src/auth/isLoginRequired.ts index b6d484a..7bd0886 100644 --- a/src/auth/isLoginRequired.ts +++ b/src/auth/isLoginRequired.ts @@ -1,5 +1,5 @@ export const isLogInRequired = (response: string): boolean => { - const pattern: RegExp = //gm + const pattern: RegExp = //gm const matches = pattern.test(response) return matches } diff --git a/src/types/Login.ts b/src/types/Login.ts index e29a2d2..cb5c832 100644 --- a/src/types/Login.ts +++ b/src/types/Login.ts @@ -6,6 +6,7 @@ export interface LoginResult { isLoggedIn: boolean userName: string userLongName: string + message?: string } export interface LoginResultInternal { isLoggedIn: boolean