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-2518] feat: log out of auth0 #49

Closed
wants to merge 8 commits into from
Closed
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
Binary file modified Content/BlueprintSampleContent/PassportFeaturesWidget4_26.uasset
Binary file not shown.
Binary file modified Content/BlueprintSampleContent/PassportLoginWidget4_26.uasset
Binary file not shown.
Binary file modified Content/PackagedResources/index.uasset
Binary file not shown.
5 changes: 5 additions & 0 deletions Source/Immutable/Immutable.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/Immutable/Immutable_UPL_Android.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
<insert>
public native void handleDeepLink(String Deeplink);

public native void handleOnCustomTabsDismissed();
public native void handleOnCustomTabsDismissed(String Url);

@Override
public void onCustomTabsDismissed() {
handleOnCustomTabsDismissed();
public void onCustomTabsDismissed(String Url) {
handleOnCustomTabsDismissed(Url);
}
</insert>
</gameActivityClassAdditions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

#include "Immutable/Actions/ImtblPassportConnectSilentAsyncAction.h"

#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Immutable/Misc/ImtblLogging.h"


UImtblPassportConnectSilentAsyncAction * UImtblPassportConnectSilentAsyncAction::ConnectSilent(UObject *WorldContextObject)
{
UImtblPassportConnectSilentAsyncAction *PassportInitBlueprintNode = NewObject<UImtblPassportConnectSilentAsyncAction>();

PassportInitBlueprintNode->WorldContextObject = WorldContextObject;

return PassportInitBlueprintNode;
}

void UImtblPassportConnectSilentAsyncAction::Activate()
{
if (!WorldContextObject || !WorldContextObject->GetWorld())
{
FString Err = "Reconnect failed due to missing world or world context object.";
IMTBL_WARN("%s", *Err)
OnFailure.Broadcast(Err);
return;
}

GetSubsystem()->WhenReady(this, &UImtblPassportConnectSilentAsyncAction:: DoConnectSilent);
}

void UImtblPassportConnectSilentAsyncAction::DoConnectSilent(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
auto Passport = GetSubsystem()->GetPassport();

if (Passport.IsValid())
{
Passport->ConnectSilent(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportConnectSilentAsyncAction::OnConnectSilentResponse));
}
}

void UImtblPassportConnectSilentAsyncAction::OnConnectSilentResponse(FImmutablePassportResult Result)
{
if (Result.Success)
{
IMTBL_LOG("Reconnect success")
OnSuccess.Broadcast(Result.Message);
}
else
{
IMTBL_LOG("Reconnect failed")
OnFailure.Broadcast(Result.Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,50 @@

#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Immutable/Misc/ImtblLogging.h"

UImtblPassportInitializationAsyncAction *
UImtblPassportInitializationAsyncAction::InitializePassport(
UObject *WorldContextObject, const FString &ClientID,
const FString &RedirectUri, const FString &Environment) {
UImtblPassportInitializationAsyncAction *PassportInitBlueprintNode =
NewObject<UImtblPassportInitializationAsyncAction>();
PassportInitBlueprintNode->ClientId = ClientID;
PassportInitBlueprintNode->RedirectUri = RedirectUri;
PassportInitBlueprintNode->Environment = Environment;
PassportInitBlueprintNode->WorldContextObject = WorldContextObject;
return PassportInitBlueprintNode;


UImtblPassportInitializationAsyncAction* UImtblPassportInitializationAsyncAction::InitializePassport(UObject* WorldContextObject, const FString& ClientID, const FString& RedirectUri,
const FString& LogoutUri, const FString& Environment)
{
UImtblPassportInitializationAsyncAction* PassportInitBlueprintNode = NewObject<UImtblPassportInitializationAsyncAction>();

PassportInitBlueprintNode->ClientId = ClientID;
PassportInitBlueprintNode->RedirectUri = RedirectUri;
PassportInitBlueprintNode->LogoutUri = LogoutUri;
PassportInitBlueprintNode->Environment = Environment;
PassportInitBlueprintNode->WorldContextObject = WorldContextObject;

return PassportInitBlueprintNode;
}

void UImtblPassportInitializationAsyncAction::Activate() {
if (!WorldContextObject || !WorldContextObject->GetWorld()) {
Failed.Broadcast(
"Initialization failed due to missing world or world context object.");
return;
}
void UImtblPassportInitializationAsyncAction::Activate()
{
if (!WorldContextObject || !WorldContextObject->GetWorld())
{
Failed.Broadcast("Initialization failed due to missing world or world context object.");
return;
}

GetSubsystem()->WhenReady(
this, &UImtblPassportInitializationAsyncAction::DoInit); //, /* timoutSec
//*/ 15.0f);
GetSubsystem()->WhenReady(this, &UImtblPassportInitializationAsyncAction::DoInit);
}

void UImtblPassportInitializationAsyncAction::DoInit(
TWeakObjectPtr<UImtblJSConnector> JSConnector) {
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run Initialize
Passport->Initialize(
FImmutablePassportInitData{ClientId, RedirectUri, Environment},
UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(
this, &UImtblPassportInitializationAsyncAction::OnInitialized));
void UImtblPassportInitializationAsyncAction::DoInit(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run Initialize
Passport->Initialize(FImmutablePassportInitData{ ClientId, RedirectUri, LogoutUri, Environment },
UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportInitializationAsyncAction::OnInitialized));
}

void UImtblPassportInitializationAsyncAction::OnInitialized(
FImmutablePassportResult Result) {
if (Result.Success) {
Initialized.Broadcast(Result.Message);
} else {
Failed.Broadcast(Result.Message);
}
void UImtblPassportInitializationAsyncAction::OnInitialized(FImmutablePassportResult Result)
{
if (Result.Success)
{
Initialized.Broadcast(Result.Message);
}
else
{
Failed.Broadcast(Result.Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,44 @@
#include "Immutable/ImmutableSubsystem.h"
#include "Immutable/Misc/ImtblLogging.h"

UImtblPassportLogoutAsyncAction *
UImtblPassportLogoutAsyncAction::Logout(UObject *WorldContextObject) {
UImtblPassportLogoutAsyncAction *PassportInitBlueprintNode =
NewObject<UImtblPassportLogoutAsyncAction>();
PassportInitBlueprintNode->WorldContextObject = WorldContextObject;
return PassportInitBlueprintNode;
UImtblPassportLogoutAsyncAction* UImtblPassportLogoutAsyncAction::Logout(UObject* WorldContextObject)
{
UImtblPassportLogoutAsyncAction* PassportInitBlueprintNode = NewObject<UImtblPassportLogoutAsyncAction>();

PassportInitBlueprintNode->WorldContextObject = WorldContextObject;

return PassportInitBlueprintNode;
}

void UImtblPassportLogoutAsyncAction::Activate() {
if (!WorldContextObject || !WorldContextObject->GetWorld()) {
FString Err = "Logout failed due to missing world or world context object.";
IMTBL_WARN("%s", *Err)
Failed.Broadcast(Err);
return;
}

GetSubsystem()->WhenReady(
this,
&UImtblPassportLogoutAsyncAction::DoLogout); //, /* timoutSec */ 15.0f);
void UImtblPassportLogoutAsyncAction::Activate()
{
if (!WorldContextObject || !WorldContextObject->GetWorld())
{
FString Err = "Logout failed due to missing world or world context object.";
IMTBL_WARN("%s", *Err)
OnFailure.Broadcast(Err);
return;
}

GetSubsystem()->WhenReady(this, &UImtblPassportLogoutAsyncAction::DoLogout); //, /* timoutSec */ 15.0f);
}

void UImtblPassportLogoutAsyncAction::DoLogout(
TWeakObjectPtr<UImtblJSConnector> JSConnector) {
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run Logout
Passport->Logout(
UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(
this, &UImtblPassportLogoutAsyncAction::OnLogoutResponse));
void UImtblPassportLogoutAsyncAction::DoLogout(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run Logout
Passport->Logout(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportLogoutAsyncAction::OnLogoutResponse));
}

void UImtblPassportLogoutAsyncAction::OnLogoutResponse(
FImmutablePassportResult Result) {
if (Result.Success) {
LoggedOut.Broadcast(Result.Message);
} else {
Failed.Broadcast(Result.Message);
}
void UImtblPassportLogoutAsyncAction::OnLogoutResponse(FImmutablePassportResult Result) const
{
if (Result.Success)
{
OnSuccess.Broadcast(Result.Message);
}
else
{
OnFailure.Broadcast(Result.Message);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
#include "ImmutableAndroidJNI.h"
#include "Immutable/ImmutablePassport.h"

#if PLATFORM_ANDROID
JNI_METHOD void
Java_com_epicgames_unreal_GameActivity_handleDeepLink(JNIEnv *env, jobject obj,
jstring jDeeplink) {
if (env->IsSameObject(jDeeplink, NULL)) {
return;
}

const char *deeplinkCStr = env->GetStringUTFChars(jDeeplink, NULL);
const FString deeplink = FString(UTF8_TO_TCHAR(deeplinkCStr));
UImmutablePassport::HandleDeepLink(deeplink);
env->ReleaseStringUTFChars(jDeeplink, deeplinkCStr);

#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Engine/GameEngine.h"

UImmutablePassport* GetPassport()
{
UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);

if (!GameEngine)
{
return nullptr;
}

UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL;

if (!World)
{
return nullptr;
}

auto ImmutableSubsystem = World->GetGameInstance()->GetSubsystem<UImmutableSubsystem>();

if (!ImmutableSubsystem)
{
return nullptr;
}

auto Passport = ImmutableSubsystem->GetPassport();

if (!Passport.IsValid())
{
return nullptr;
}

return Passport.Get();
}

JNI_METHOD void Java_com_epicgames_unreal_GameActivity_handleDeepLink(JNIEnv *env, jobject obj, jstring jDeeplink)
{
if (env->IsSameObject(jDeeplink, NULL))
{
return;
}

const char *deeplinkCStr = env->GetStringUTFChars(jDeeplink, NULL);
const FString deeplink = FString(UTF8_TO_TCHAR(deeplinkCStr));

if (auto Passport = GetPassport())
{
Passport->HandleDeepLink(deeplink);
}
env->ReleaseStringUTFChars(jDeeplink, deeplinkCStr);
}

JNI_METHOD void
Java_com_epicgames_unreal_GameActivity_handleOnCustomTabsDismissed(
JNIEnv *env, jobject obj) {
UImmutablePassport::HandleCustomTabsDismissed();
JNI_METHOD void Java_com_epicgames_unreal_GameActivity_handleOnCustomTabsDismissed(JNIEnv *env, jobject obj, jstring jUrl)
{
if (env->IsSameObject(jUrl, NULL))
{
return;
}

if (auto Passport = GetPassport())
{
Passport->HandleCustomTabsDismissed(FString(UTF8_TO_TCHAR(env->GetStringUTFChars(jUrl, NULL))));
}
}
#endif
Loading
Loading