Skip to content

Commit 7db5c89

Browse files
feat(Logout): use quartz logout endpoint (#6020)
1 parent 07c1f9f commit 7db5c89

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/Logout.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import {useHistory} from 'react-router-dom'
77
import {postSignout} from 'src/client'
88

99
// Constants
10-
import {CLOUD, CLOUD_SIGNOUT_PATHNAME} from 'src/shared/constants'
10+
import {
11+
CLOUD,
12+
CLOUD_LOGOUT_PATH,
13+
CLOUD_SIGNOUT_PATHNAME,
14+
} from 'src/shared/constants'
1115

1216
// Components
1317
import {reset} from 'src/shared/actions/flags'
18+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1419

1520
const Logout: FC = () => {
1621
const history = useHistory()
@@ -19,6 +24,17 @@ const Logout: FC = () => {
1924
useEffect(() => {
2025
const handleSignOut = async () => {
2126
if (CLOUD) {
27+
if (isFlagEnabled('universalLogin')) {
28+
fetch('/api/env/quartz-login-url')
29+
.then(async response => {
30+
const quartzUrl = await response.text()
31+
const redirectUrl = `${quartzUrl}${CLOUD_LOGOUT_PATH}`
32+
console.warn('Redirect to cloud url: ', redirectUrl)
33+
window.location.replace(`${redirectUrl}`)
34+
})
35+
.catch(error => console.error(error))
36+
return null
37+
}
2238
const url = new URL(
2339
`${window.location.origin}${CLOUD_SIGNOUT_PATHNAME}`
2440
).href

src/onboarding/containers/LoginPage.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,10 @@ export const LoginPage: FC = () => {
5757
if (isFlagEnabled('universalLogin')) {
5858
if (CLOUD) {
5959
fetch('/api/env/quartz-login-url')
60-
.then(response => {
61-
response
62-
.text()
63-
.then(response => {
64-
const redirectUrl = response
65-
console.warn('Redirect to cloud url: ', redirectUrl)
66-
window.location.replace(redirectUrl)
67-
})
68-
.catch(error => {
69-
console.error(
70-
'Failed to fetch /api/env/quartz-login-url',
71-
error
72-
)
73-
})
60+
.then(async response => {
61+
const quartzUrl = await response.text()
62+
console.warn('Redirect to cloud url: ', quartzUrl)
63+
window.location.replace(quartzUrl)
7464
})
7565
.catch(error => console.error(error))
7666
return null

0 commit comments

Comments
 (0)