Skip to content

Commit 9afcd4b

Browse files
committed
refactor: better direct login method checking
1 parent b4a2f5b commit 9afcd4b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ private async void HandleLoginData(string jsonData)
274274
LoginData loginData = JsonUtility.FromJson<LoginData>(jsonData);
275275
PassportLogger.Info($"{TAG} Parsed login data: {loginData}");
276276

277+
// Validate required login data
278+
if (string.IsNullOrEmpty(loginData.directLoginMethod))
279+
{
280+
PassportLogger.Error($"{TAG} Login method is required but was null or empty");
281+
return;
282+
}
283+
277284
// For now, just log the data - in the future this could trigger OAuth flow
278285
PassportLogger.Info($"{TAG} Login attempt - Method: {loginData.directLoginMethod}, Email: {loginData.email}, Marketing Consent: {loginData.marketingConsentStatus}");
279286

@@ -298,8 +305,16 @@ private async void HandleLoginData(string jsonData)
298305
return;
299306
}
300307
var loginOptions = new DirectLoginOptions(loginMethod);
301-
if (loginData.email != null)
308+
309+
// Validate email is provided for email login method
310+
if (loginMethod == DirectLoginMethod.Email)
302311
{
312+
if (string.IsNullOrEmpty(loginData.email))
313+
{
314+
PassportLogger.Error($"{TAG} Email is required for email login method but was null or empty");
315+
return;
316+
}
317+
303318
loginOptions.email = loginData.email;
304319
}
305320

0 commit comments

Comments
 (0)