Skip to content

Commit 13fc6b5

Browse files
committed
refactor: update login data interface to match embedded prompt page update
1 parent fca7fe6 commit 13fc6b5

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/Packages/Passport/Runtime/Scripts/Public/PassportUI.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@ namespace Immutable.Passport
1818
{
1919
/// <summary>
2020
/// Data structure for login information received from JavaScript
21+
/// Matches the TypeScript LoginData interface from the web page
2122
/// </summary>
2223
[System.Serializable]
2324
public class LoginData
2425
{
25-
public string provider;
26+
public string directLoginMethod;
2627
public string email;
27-
public bool marketing_consent;
28+
public string marketingConsentStatus;
2829

2930
public override string ToString()
3031
{
31-
return $"LoginData(provider: {provider}, email: {email}, marketing_consent: {marketing_consent})";
32+
return $"LoginData(directLoginMethod: {directLoginMethod}, email: {email}, marketingConsentStatus: {marketingConsentStatus})";
3233
}
3334
}
3435

3536
/// <summary>
36-
/// PassportUI that follows the working WebViewTest pattern
37-
/// Key difference: Let Unity handle component lifecycle instead of manual initialization
37+
/// Cross-platform WebView UI component for Passport authentication.
38+
/// Automatically selects the appropriate WebView implementation based on the target platform:
39+
/// - Windows: Unity Web Browser (UWB) with Chromium CEF
40+
/// - iOS/Android: Gree unity-webview with external browser integration
41+
/// - macOS: Not yet implemented
3842
///
39-
/// IMPORTANT: When setting up the PassportUI prefab in the editor:
43+
/// SETUP: When configuring the PassportUI prefab in the editor:
4044
/// - Set RawImage component's width and height to 0 in the RectTransform
4145
/// - This ensures the UI is completely hidden before initialization
4246
///
@@ -256,11 +260,11 @@ private async void HandleLoginData(string jsonData)
256260
PassportLogger.Info($"{TAG} Parsed login data: {loginData}");
257261

258262
// For now, just log the data - in the future this could trigger OAuth flow
259-
PassportLogger.Info($"{TAG} Login attempt - Provider: {loginData.provider}, Email: {loginData.email}, Marketing Consent: {loginData.marketing_consent}");
263+
PassportLogger.Info($"{TAG} Login attempt - Method: {loginData.directLoginMethod}, Email: {loginData.email}, Marketing Consent: {loginData.marketingConsentStatus}");
260264

261265
// Login(bool useCachedSession = false, DirectLoginOptions directLoginOptions = null)
262266
DirectLoginMethod loginMethod;
263-
switch (loginData.provider)
267+
switch (loginData.directLoginMethod)
264268
{
265269
case "email":
266270
loginMethod = DirectLoginMethod.Email;
@@ -275,7 +279,7 @@ private async void HandleLoginData(string jsonData)
275279
loginMethod = DirectLoginMethod.Facebook;
276280
break;
277281
default:
278-
PassportLogger.Error($"{TAG} Invalid login provider: {loginData.provider}");
282+
PassportLogger.Error($"{TAG} Invalid login method: {loginData.directLoginMethod}");
279283
return;
280284
}
281285
var loginOptions = new DirectLoginOptions(loginMethod);
@@ -285,7 +289,7 @@ private async void HandleLoginData(string jsonData)
285289
}
286290

287291
// Perform the login and handle the result
288-
PassportLogger.Info($"{TAG} Starting login with provider: {loginData.provider}");
292+
PassportLogger.Info($"{TAG} Starting login with method: {loginData.directLoginMethod}");
289293
bool loginSuccess = await _passportInstance.Login(false, loginOptions);
290294

291295
if (loginSuccess)
@@ -408,7 +412,7 @@ public async UniTask<bool> ShowLoginUI()
408412

409413
// TESTING: Load local test page instead of auth URL
410414
PassportLogger.Info($"{TAG} 🧪 Loading local test page for development");
411-
string testPageUrl = "http://localhost:8080";
415+
string testPageUrl = "http://localhost:3001";
412416
PassportLogger.Info($"{TAG} Test page URL: {testPageUrl}");
413417

414418
// Show the WebView

0 commit comments

Comments
 (0)