@@ -615,6 +615,7 @@ void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response)
615615 {
616616 IMTBL_ERR (" Unable to return a response for Connect PKCE" );
617617 }
618+ ResetStateFlags (IPS_COMPLETING_PKCE);
618619}
619620#endif
620621
@@ -958,7 +959,10 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink)
958959
959960void UImmutablePassport::CompleteLoginPKCEFlow (FString Url)
960961{
961- SetStateFlags (IPS_CONNECTED);
962+ // Required mainly for Android to detect when Chrome Custom tabs is dismissed
963+ // See HandleOnLoginPKCEDismissed
964+ SetStateFlags (IPS_COMPLETING_PKCE);
965+
962966 // Get code and state from deeplink URL
963967 TOptional<FString> Code, State;
964968 FString Endpoint, Params;
@@ -989,7 +993,7 @@ void UImmutablePassport::CompleteLoginPKCEFlow(FString Url)
989993 IMTBL_ERR (" %s" , *ErrorMsg);
990994 PKCEResponseDelegate.ExecuteIfBound (FImmutablePassportResult{false , ErrorMsg});
991995 PKCEResponseDelegate = nullptr ;
992- ResetStateFlags (IPS_PKCE|IPS_CONNECTING);
996+ ResetStateFlags (IPS_PKCE|IPS_CONNECTING|IPS_COMPLETING_PKCE );
993997 }
994998 else
995999 {
@@ -1028,7 +1032,12 @@ void UImmutablePassport::HandleOnLoginPKCEDismissed()
10281032 IMTBL_LOG (" Handle On Login PKCE Dismissed" );
10291033 OnPKCEDismissed = nullptr ;
10301034
1031- if (IsStateFlagSet (IPS_CONNECTING))
1035+ // If the second part of PKCE (CompleteLoginPKCEFlow) has not started yet and custom tabs is dismissed,
1036+ // this means the user manually dismissed the custom tabs before entering all
1037+ // all required details (e.g. email address) into Passport
1038+ // Cannot use IPS_CONNECTING as that is set when PKCE flow is initiated. Here we are checking against the second
1039+ // half of the PKCE flow.
1040+ if (!IsStateFlagSet (IPS_COMPLETING_PKCE))
10321041 {
10331042 // User hasn't entered all required details (e.g. email address) into
10341043 // Passport yet
0 commit comments