Skip to content

Commit

Permalink
Merge pull request #999 from PlayEveryWare/teach-eosmanager-grabuserinfo
Browse files Browse the repository at this point in the history
feat: EOSManager can have UserLoginInfo Provided to it
  • Loading branch information
WispyMouse authored Nov 7, 2024
2 parents 6fc03e9 + 6fb5e89 commit bf26985
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions com.playeveryware.eos/Runtime/Core/EOSManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace PlayEveryWare.EpicOnlineServices
using LogoutCallbackInfo = Epic.OnlineServices.Auth.LogoutCallbackInfo;
using LogoutOptions = Epic.OnlineServices.Auth.LogoutOptions;
using OnLogoutCallback = Epic.OnlineServices.Auth.OnLogoutCallback;
using System.Threading.Tasks;
#endif
/// <summary>
/// One of the responsibilities of this class is to manage the lifetime of
Expand All @@ -106,10 +107,20 @@ public partial class EOSManager : MonoBehaviour, IEOSCoroutineOwner

public delegate void OnConnectLoginCallback(Epic.OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo);

public delegate Task<UserLoginInfo> GetUserLoginInfoDelegate();

private static event OnAuthLoginCallback OnAuthLogin;
private static event OnAuthLogoutCallback OnAuthLogout;
private static event OnConnectLoginCallback OnConnectLogin;

/// <summary>
/// Some platforms require additional user information while performing
/// a connect login. This delegate can be provided to saturate a
/// UserLoginInfo during <see cref="StartConnectLoginWithEpicAccount"/>.
/// If this is not provided, no UserLoginInfo will be set.
/// </summary>
public static GetUserLoginInfoDelegate GetUserLoginInfo = null;

public delegate void OnCreateConnectUserCallback(CreateUserCallbackInfo createUserCallbackInfo);

public delegate void OnConnectLinkExternalAccountCallback(LinkAccountCallbackInfo linkAccountCallbackInfo);
Expand Down Expand Up @@ -1040,11 +1051,21 @@ public void ConnectLinkExternalAccountWithContinuanceToken(ContinuanceToken toke

//-------------------------------------------------------------------------
/// <summary>
///
/// Starts a Connect Login using a provided EpicAccountId.
/// If <see cref="GetUserLoginInfoDelegate"/> is set, this will
/// use that delegate to determine the
/// <see cref="Epic.OnlineServices.Connect.LoginOptions.UserLoginInfo"/>.
/// </summary>
/// <param name="epicAccountId"></param>
/// <param name="onConnectLoginCallback"></param>
public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
/// <param name="epicAccountId">
/// The Epic Account to login as.
/// This is provided by logging in through the Auth interface.
/// </param>
/// <param name="onConnectLoginCallback">
/// Callback to run with information about the results of the login.
/// Also contains the information needed to set ProductUserId.
/// <see cref="s_localProductUserId"/>
/// </param>
public async void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
OnConnectLoginCallback onConnectLoginCallback)
{
var EOSAuthInterface = GetEOSPlatformInterface().GetAuthInterface();
Expand Down Expand Up @@ -1079,6 +1100,13 @@ public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
return;
}

// If the GetUserLoginInfo delegate is set, the UserLoginInfo can
// be provided here for platforms that require it in this scenario.
if (EOSManager.GetUserLoginInfo != null)
{
connectLoginOptions.UserLoginInfo = await EOSManager.GetUserLoginInfo();
}

// If the authToken returned a value, and there is a RefreshToken, then try to login using that
// Otherwise, try to use the AccessToken if that's available
// One or the other should be provided, but if neither is available then fail to login
Expand Down

0 comments on commit bf26985

Please sign in to comment.