1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-16 16:40:06 +00:00

fix: username returns from checkSession

This commit is contained in:
Saad Jutt
2021-09-01 03:49:44 +05:00
parent e4d669f9b6
commit 2a6e29b5b8

View File

@@ -38,15 +38,19 @@ export class AuthManager {
password password
} }
let { isLoggedIn, loginForm, userName } = await this.checkSession() let {
isLoggedIn: isLoggedInAlready,
loginForm,
userName: currentSessionUsername
} = await this.checkSession()
if (isLoggedIn) { if (isLoggedInAlready) {
if (userName === loginParams.username) { if (currentSessionUsername === loginParams.username) {
await this.loginCallback() await this.loginCallback()
this.userName = userName! this.userName = currentSessionUsername!
return { return {
isLoggedIn, isLoggedIn: true,
userName: this.userName userName: this.userName
} }
} else { } else {
@@ -56,7 +60,7 @@ export class AuthManager {
let loginResponse = await this.sendLoginRequest(loginForm, loginParams) let loginResponse = await this.sendLoginRequest(loginForm, loginParams)
isLoggedIn = isLogInSuccess(loginResponse) let isLoggedIn = isLogInSuccess(loginResponse)
if (!isLoggedIn) { if (!isLoggedIn) {
if (isCredentialsVerifyError(loginResponse)) { if (isCredentialsVerifyError(loginResponse)) {
@@ -65,13 +69,15 @@ export class AuthManager {
loginResponse = await this.sendLoginRequest(newLoginForm, loginParams) loginResponse = await this.sendLoginRequest(newLoginForm, loginParams)
} }
;({ isLoggedIn, userName } = await this.checkSession()) const res = await this.checkSession()
isLoggedIn = res.isLoggedIn
if (isLoggedIn) this.userName = res.userName!
} else { } else {
this.userName = loginParams.username this.userName = loginParams.username
} }
if (isLoggedIn) { if (isLoggedIn) {
this.userName = userName!
if (this.serverType === ServerType.Sas9) { if (this.serverType === ServerType.Sas9) {
const casAuthenticationUrl = `${this.serverUrl}/SASStoredProcess/j_spring_cas_security_check` const casAuthenticationUrl = `${this.serverUrl}/SASStoredProcess/j_spring_cas_security_check`