Skip to content

Commit d9e478b

Browse files
committed
Merge pull request #999 from PlayEveryWare/teach-eosmanager-grabuserinfo
feat: EOSManager can have UserLoginInfo Provided to it
1 parent 0cc038f commit d9e478b

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

com.playeveryware.eos/Runtime/Core/EOSManager.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace PlayEveryWare.EpicOnlineServices
8686
using LogoutCallbackInfo = Epic.OnlineServices.Auth.LogoutCallbackInfo;
8787
using LogoutOptions = Epic.OnlineServices.Auth.LogoutOptions;
8888
using OnLogoutCallback = Epic.OnlineServices.Auth.OnLogoutCallback;
89+
using System.Threading.Tasks;
8990
#endif
9091
/// <summary>
9192
/// One of the responsibilities of this class is to manage the lifetime of
@@ -106,10 +107,20 @@ public partial class EOSManager : MonoBehaviour, IEOSCoroutineOwner
106107

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

110+
public delegate Task<UserLoginInfo> GetUserLoginInfoDelegate();
111+
109112
private static event OnAuthLoginCallback OnAuthLogin;
110113
private static event OnAuthLogoutCallback OnAuthLogout;
111114
private static event OnConnectLoginCallback OnConnectLogin;
112115

116+
/// <summary>
117+
/// Some platforms require additional user information while performing
118+
/// a connect login. This delegate can be provided to saturate a
119+
/// UserLoginInfo during <see cref="StartConnectLoginWithEpicAccount"/>.
120+
/// If this is not provided, no UserLoginInfo will be set.
121+
/// </summary>
122+
public static GetUserLoginInfoDelegate GetUserLoginInfo = null;
123+
113124
public delegate void OnCreateConnectUserCallback(CreateUserCallbackInfo createUserCallbackInfo);
114125

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

10411052
//-------------------------------------------------------------------------
10421053
/// <summary>
1043-
///
1054+
/// Starts a Connect Login using a provided EpicAccountId.
1055+
/// If <see cref="GetUserLoginInfoDelegate"/> is set, this will
1056+
/// use that delegate to determine the
1057+
/// <see cref="Epic.OnlineServices.Connect.LoginOptions.UserLoginInfo"/>.
10441058
/// </summary>
1045-
/// <param name="epicAccountId"></param>
1046-
/// <param name="onConnectLoginCallback"></param>
1047-
public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
1059+
/// <param name="epicAccountId">
1060+
/// The Epic Account to login as.
1061+
/// This is provided by logging in through the Auth interface.
1062+
/// </param>
1063+
/// <param name="onConnectLoginCallback">
1064+
/// Callback to run with information about the results of the login.
1065+
/// Also contains the information needed to set ProductUserId.
1066+
/// <see cref="s_localProductUserId"/>
1067+
/// </param>
1068+
public async void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
10481069
OnConnectLoginCallback onConnectLoginCallback)
10491070
{
10501071
var EOSAuthInterface = GetEOSPlatformInterface().GetAuthInterface();
@@ -1079,6 +1100,13 @@ public void StartConnectLoginWithEpicAccount(EpicAccountId epicAccountId,
10791100
return;
10801101
}
10811102

1103+
// If the GetUserLoginInfo delegate is set, the UserLoginInfo can
1104+
// be provided here for platforms that require it in this scenario.
1105+
if (EOSManager.GetUserLoginInfo != null)
1106+
{
1107+
connectLoginOptions.UserLoginInfo = await EOSManager.GetUserLoginInfo();
1108+
}
1109+
10821110
// If the authToken returned a value, and there is a RefreshToken, then try to login using that
10831111
// Otherwise, try to use the AccessToken if that's available
10841112
// One or the other should be provided, but if neither is available then fail to login

0 commit comments

Comments
 (0)