Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX-2615] fix: android custom tabs dismiss callback #63

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Source/Immutable/Private/Immutable/ImmutablePassport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response)
{
IMTBL_ERR("Unable to return a response for Connect PKCE");
}
ResetStateFlags(IPS_COMPLETING_PKCE);
}
#endif

Expand Down Expand Up @@ -958,7 +959,10 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink)

void UImmutablePassport::CompleteLoginPKCEFlow(FString Url)
{
SetStateFlags(IPS_CONNECTED);
// Required mainly for Android to detect when Chrome Custom tabs is dismissed
// See HandleOnLoginPKCEDismissed
SetStateFlags(IPS_COMPLETING_PKCE);

// Get code and state from deeplink URL
TOptional<FString> Code, State;
FString Endpoint, Params;
Expand Down Expand Up @@ -989,7 +993,7 @@ void UImmutablePassport::CompleteLoginPKCEFlow(FString Url)
IMTBL_ERR("%s", *ErrorMsg);
PKCEResponseDelegate.ExecuteIfBound(FImmutablePassportResult{false, ErrorMsg});
PKCEResponseDelegate = nullptr;
ResetStateFlags(IPS_PKCE|IPS_CONNECTING);
ResetStateFlags(IPS_PKCE|IPS_CONNECTING|IPS_COMPLETING_PKCE);
}
else
{
Expand Down Expand Up @@ -1028,7 +1032,12 @@ void UImmutablePassport::HandleOnLoginPKCEDismissed()
IMTBL_LOG("Handle On Login PKCE Dismissed");
OnPKCEDismissed = nullptr;

if (IsStateFlagSet(IPS_CONNECTING))
// If the second part of PKCE (CompleteLoginPKCEFlow) has not started yet and custom tabs is dismissed,
// this means the user manually dismissed the custom tabs before entering all
// all required details (e.g. email address) into Passport
// Cannot use IPS_CONNECTING as that is set when PKCE flow is initiated. Here we are checking against the second
// half of the PKCE flow.
if (!IsStateFlagSet(IPS_COMPLETING_PKCE))
{
// User hasn't entered all required details (e.g. email address) into
// Passport yet
Expand Down
3 changes: 2 additions & 1 deletion Source/Immutable/Public/Immutable/ImmutablePassport.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ class IMMUTABLE_API UImmutablePassport : public UObject
IPS_CONNECTED = 1 << 1,
IPS_IMX = 1 << 2,
IPS_PKCE = 1 << 3,
IPS_INITIALIZED = 1 << 4
IPS_COMPLETING_PKCE = 1 << 4,
IPS_INITIALIZED = 1 << 5
};

uint8 StateFlags = IPS_NONE;
Expand Down
Loading