File tree Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Expand file tree Collapse file tree 2 files changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,15 @@ import {useHistory} from 'react-router-dom'
77import { 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
1317import { reset } from 'src/shared/actions/flags'
18+ import { isFlagEnabled } from 'src/shared/utils/featureFlag'
1419
1520const 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments