public void startSignIn()

in auth/src/main/java/com/firebase/ui/auth/viewmodel/email/EmailLinkSignInHandler.java [43:100]


    public void startSignIn() {
        setResult(Resource.forLoading());

        String link = getArguments().emailLink;
        if (!getAuth().isSignInWithEmailLink(link)) {
            setResult(Resource.forFailure(
                    new FirebaseUiException(ErrorCodes.INVALID_EMAIL_LINK_ERROR)));
            return;
        }

        final EmailLinkPersistenceManager persistenceManager = EmailLinkPersistenceManager
                .getInstance();

        SessionRecord sessionRecord = persistenceManager.retrieveSessionRecord(getApplication());

        EmailLinkParser parser = new EmailLinkParser(link);
        String sessionIdFromLink = parser.getSessionId();
        String anonymousUserIdFromLink = parser.getAnonymousUserId();
        String oobCodeFromLink = parser.getOobCode();
        String providerIdFromLink = parser.getProviderId();
        boolean forceSameDevice = parser.getForceSameDeviceBit();

        if (isDifferentDeviceFlow(sessionRecord, sessionIdFromLink)) {
            if (TextUtils.isEmpty(sessionIdFromLink)) {
                // There should always be a valid session ID in the link
                setResult(Resource.forFailure(
                        new FirebaseUiException(ErrorCodes.INVALID_EMAIL_LINK_ERROR)));
                return;
            }
            if (forceSameDevice || !TextUtils.isEmpty(anonymousUserIdFromLink)) {
                // In both cases, the link was meant to be completed on the same device.
                // For anonymous user upgrade, we don't support the cross device flow.
                setResult(Resource.forFailure(
                        new FirebaseUiException(ErrorCodes.EMAIL_LINK_WRONG_DEVICE_ERROR)));
                return;
            }

            // If we have no SessionRecord/there is a session ID mismatch, this means that we were
            // not the ones to send the link. The only way forward is to prompt the user for their
            // email before continuing the flow. We should only do that after validating the link.
            determineDifferentDeviceErrorFlowAndFinish(oobCodeFromLink, providerIdFromLink);
            return;
        }

        if (anonymousUserIdFromLink != null){
            // Same device flow, need to ensure uids match
            if (getAuth().getCurrentUser() == null
                    || (getAuth().getCurrentUser().isAnonymous()
                    && !anonymousUserIdFromLink.equals(getAuth().getCurrentUser().getUid()))) {
                setResult(Resource.forFailure(
                        new FirebaseUiException(
                                ErrorCodes.EMAIL_LINK_DIFFERENT_ANONYMOUS_USER_ERROR)));
                return;
            }
        }

        finishSignIn(sessionRecord);
    }