(shouldVerify?: boolean)
| 428 | }; |
| 429 | |
| 430 | const onLoginCheck = async (shouldVerify?: boolean) => { |
| 431 | if (shouldVerify) { |
| 432 | setEmailVerificationReturn(AuthDisplay.Default); |
| 433 | onSetActiveDisplay(AuthDisplay.EmailVerification); |
| 434 | return; |
| 435 | } |
| 436 | |
| 437 | if (isRegistration) { |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | if (!user || handleLoginCheck === false) { |
| 442 | return; |
| 443 | } |
| 444 | |
| 445 | setHandleLoginCheck(handleLoginCheck === null); |
| 446 | |
| 447 | if (user.infoConfirmed) { |
| 448 | logEvent({ |
| 449 | event_name: AuthEventNames.LoginSuccessfully, |
| 450 | }); |
| 451 | |
| 452 | // Check for claimable items on login (e.g., Plus subscription) |
| 453 | claimClaimableItem().then((hasClaimed) => { |
| 454 | if (hasClaimed) { |
| 455 | refetchBoot(); |
| 456 | } |
| 457 | }); |
| 458 | |
| 459 | const isAlreadyOnboarded = await checkForOnboardedUser(user); |
| 460 | if (!isAlreadyOnboarded) { |
| 461 | onSuccessfulLogin?.(); |
| 462 | } |
| 463 | } else if (autoProfileTriggers.includes(trigger)) { |
| 464 | await autoCompleteProfile(user.email, user.name); |
| 465 | } else { |
| 466 | onSetActiveDisplay(AuthDisplay.SocialRegistration); |
| 467 | } |
| 468 | }; |
| 469 | |
| 470 | useEffect(() => { |
| 471 | onLoginCheck(); |
no test coverage detected