@@ -26,7 +26,7 @@ const ConfigOAuth = () => {
26
26
27
27
const ssoFlowRef = useRef ( ssoFlow )
28
28
const isRecommendedSettingsRef = useRef ( isRecommendedSettings )
29
- const isFlowStarted = useRef ( ! ! ssoFlow )
29
+ const isFlowInProgress = useRef ( false )
30
30
31
31
const history = useHistory ( )
32
32
const dispatch = useDispatch ( )
@@ -37,7 +37,10 @@ const ConfigOAuth = () => {
37
37
38
38
useEffect ( ( ) => {
39
39
ssoFlowRef . current = ssoFlow
40
- isFlowStarted . current = ! ! ssoFlow
40
+
41
+ if ( ! ssoFlow ) {
42
+ isFlowInProgress . current = false
43
+ }
41
44
} , [ ssoFlow ] )
42
45
43
46
useEffect ( ( ) => {
@@ -91,18 +94,23 @@ const ConfigOAuth = () => {
91
94
}
92
95
93
96
const cloudOauthCallback = ( _e : any , { status, message = '' , error } : CloudAuthResponse ) => {
94
- if ( ! isFlowStarted . current ) return
95
-
96
97
if ( status === CloudAuthStatus . Succeed ) {
97
98
dispatch ( setJob ( { id : '' , name : CloudJobName . CreateFreeSubscriptionAndDatabase , status : '' } ) )
98
99
localStorageService . remove ( BrowserStorageItem . OAuthJobId )
99
100
dispatch ( showOAuthProgress ( true ) )
100
101
dispatch ( addInfiniteNotification ( INFINITE_MESSAGES . AUTHENTICATING ( ) ) )
101
102
dispatch ( setSocialDialogState ( null ) )
102
103
dispatch ( fetchUserInfo ( fetchUserInfoSuccess , closeInfinityNotification ) )
104
+ isFlowInProgress . current = true
103
105
}
104
106
105
107
if ( status === CloudAuthStatus . Failed ) {
108
+ // don't do anything, because we are processing something
109
+ // covers situation when were made several clicks on the same time
110
+ if ( isFlowInProgress . current ) {
111
+ return
112
+ }
113
+
106
114
const err = parseCloudOAuthError ( ( error as CustomError ) || message || '' )
107
115
dispatch ( setOAuthCloudSource ( null ) )
108
116
dispatch ( signInFailure ( err ?. response ?. data ?. message || message ) )
0 commit comments