diff --git a/Content/BlueprintSampleContent/PassportFeaturesWidget4_26.uasset b/Content/BlueprintSampleContent/PassportFeaturesWidget4_26.uasset index 2ab066c..023b6e7 100644 Binary files a/Content/BlueprintSampleContent/PassportFeaturesWidget4_26.uasset and b/Content/BlueprintSampleContent/PassportFeaturesWidget4_26.uasset differ diff --git a/Source/Immutable/Immutable.Build.cs b/Source/Immutable/Immutable.Build.cs index 9bb9c4d..27b42bc 100644 --- a/Source/Immutable/Immutable.Build.cs +++ b/Source/Immutable/Immutable.Build.cs @@ -79,6 +79,11 @@ public Immutable(ReadOnlyTargetRules Target) : base(Target) // ... add any modules that your module loads dynamically here ... } ); + + if (Target.bBuildEditor == true) + { + PrivateDependencyModuleNames.Add("UnrealEd"); + } if (Target.Platform == UnrealTargetPlatform.Android) { diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportLogoutAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportLogoutAsyncAction.cpp index f7ac274..a606a37 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportLogoutAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportLogoutAsyncAction.cpp @@ -21,7 +21,7 @@ void UImtblPassportLogoutAsyncAction::Activate() { FString Err = "Logout failed due to missing world or world context object."; IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err); + OnFailure.Broadcast(Err); return; } @@ -36,14 +36,14 @@ void UImtblPassportLogoutAsyncAction::DoLogout(TWeakObjectPtr Passport->Logout(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportLogoutAsyncAction::OnLogoutResponse)); } -void UImtblPassportLogoutAsyncAction::OnLogoutResponse(FImmutablePassportResult Result) +void UImtblPassportLogoutAsyncAction::OnLogoutResponse(FImmutablePassportResult Result) const { if (Result.Success) { - LoggedOut.Broadcast(Result.Message); + OnSuccess.Broadcast(Result.Message); } else { - Failed.Broadcast(Result.Message); + OnFailure.Broadcast(Result.Message); } } diff --git a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp index 19f3c90..695c55a 100644 --- a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp +++ b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp @@ -148,7 +148,10 @@ void UImmutablePassport::Initialize(const FImmutablePassportInitData& Data, void UImmutablePassport::Logout(const FImtblPassportResponseDelegate& ResponseDelegate) { #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC - PKCELogoutResponseDelegate = ResponseDelegate; + if (bIsLoggedIn && IsPKCEConnected) + { + PKCELogoutResponseDelegate = ResponseDelegate; + } #endif CallJS(ImmutablePassportAction::Logout, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnLogoutResponse)); @@ -543,8 +546,6 @@ void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response) else { IMTBL_ERR("Unable to return a response for Connect PKCE"); - PKCEResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ false, "Response delegate is not assigned" }); - PKCEResponseDelegate = nullptr; } } @@ -882,8 +883,9 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink) { IMTBL_LOG_FUNC("URL : %s", *DeepLink); OnHandleDeepLink = nullptr; - if (DeepLink.StartsWith(InitData.logoutRedirectUri) && PKCELogoutResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ true, "Logged out" })) + if (DeepLink.StartsWith(InitData.logoutRedirectUri)) { + PKCELogoutResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ true, "Logged out" }); PKCELogoutResponseDelegate = nullptr; IsPKCEConnected = false; } diff --git a/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp b/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp index 1eebcfe..411f744 100644 --- a/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp +++ b/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp @@ -3,6 +3,10 @@ #include "Immutable/ImmutableSubsystem.h" #include "Engine/GameEngine.h" +#if WITH_EDITOR +#include "Editor.h" +#endif + ASWebAuthenticationSession *_authSession; @implementation ImmutableMac @@ -22,13 +26,26 @@ ASWebAuthenticationSession *_authSession; } + (UImmutablePassport*) getPassport { - UGameEngine* GameEngine = Cast(GEngine); - - if (!GameEngine) { - return nil; + UWorld* World = nullptr; + +#if WITH_EDITOR + if (GEditor) + { + for (const auto& Context : GEditor->GetWorldContexts()) + { + if (Context.WorldType == EWorldType::PIE && Context.World()) + { + World = Context.World(); + break; + } + } } - - UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL; +#else + if (UGameEngine* GameEngine = Cast(GEngine)) + { + World = GameEngine->GetGameWorld(); + } +#endif if (!World) { return nil; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h index 88da586..fe24f7b 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h @@ -1,6 +1,4 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once +#pragma once #include "CoreMinimal.h" #include "Immutable/ImmutablePassport.h" @@ -12,28 +10,29 @@ */ // UCLASS(meta = (HasDedicatedAsyncNode)) UCLASS() -class IMMUTABLE_API UImtblPassportLogoutAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportLogoutAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportLogoutOutputPin, FString, - ErrorMessage); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportLogoutOutPin, FString, Message); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportLogoutAsyncAction *Logout(UObject *WorldContextObject); + + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportLogoutAsyncAction* Logout(UObject* WorldContextObject); + + virtual void Activate() override; + +private: - void Activate() override; + void DoLogout(TWeakObjectPtr JSConnector); + void OnLogoutResponse(FImmutablePassportResult Result) const; private: - void DoLogout(TWeakObjectPtr JSConnector); - void OnLogoutResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportLogoutOutputPin LoggedOut; - UPROPERTY(BlueprintAssignable) - FPassportLogoutOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportLogoutOutPin OnSuccess; + UPROPERTY(BlueprintAssignable) + FPassportLogoutOutPin OnFailure; + };