Skip to content

Commit c1a4141

Browse files
authored
Merge pull request #319 from sasjs/issue-318
fix: local login component should not pop up when login mechanism is …
2 parents fcf567e + 01676f6 commit c1a4141

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/context/sasContext.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ const SASProvider = (props: { children: ReactNode }) => {
138138
if (!startupData) {
139139
fetchStartupData()
140140
}
141+
} else if (sasjsConfig.loginMechanism === 'Redirected') {
142+
sasService
143+
.logIn()
144+
.then(
145+
(res: { isLoggedIn: boolean; userName: string }) => {
146+
setIsUserLoggedIn(res.isLoggedIn)
147+
},
148+
(err) => {
149+
console.error(err)
150+
setIsUserLoggedIn(false)
151+
}
152+
)
153+
.catch((e) => {
154+
if (e === 403) {
155+
console.error('Invalid host')
156+
}
157+
})
141158
}
142159
}, [isUserLoggedIn, startupData, fetchStartupData])
143160

src/layouts/Main.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ const Main = (props) => {
192192
open={open}
193193
/>
194194
</div>
195-
{!(sasContext.isUserLoggedIn || sasContext.checkingSession) && (
196-
<LoginComponent />
197-
)}
195+
{!(
196+
window.sasjsConfig.loginMechanism === 'Redirected' ||
197+
sasContext.isUserLoggedIn ||
198+
sasContext.checkingSession
199+
) && <LoginComponent />}
198200
</>
199201
)
200202
}

0 commit comments

Comments
 (0)