Пример #1
0
        private async Task signup()
        {
            var shakeTargets = ShakeTargets.None;

            if (!emailSubject.Value.IsValid)
            {
                shakeTargets |= ShakeTargets.Email;
            }
            if (!passwordSubject.Value.IsValid)
            {
                shakeTargets |= ShakeTargets.Password;
            }
            if (!countryId.HasValue)
            {
                shakeTargets |= ShakeTargets.Country;
            }

            if (shakeTargets != ShakeTargets.None)
            {
                shakeSubject.OnNext(shakeTargets);
                return;
            }

            await requestAcceptanceOfTermsAndConditionsIfNeeded();

            if (!termsOfServiceAccepted || isLoadingSubject.Value)
            {
                return;
            }

            isLoadingSubject.OnNext(true);
            errorMessageSubject.OnNext(string.Empty);

            var supportedTimezonesObs = interactorFactory.GetSupportedTimezones().Execute();

            signupDisposable = supportedTimezonesObs
                               .Select(supportedTimezones => supportedTimezones.FirstOrDefault(tz => platformInfo.TimezoneIdentifier == tz))
                               .SelectMany(timezone
                                           => userAccessManager
                                           .SignUp(
                                               emailSubject.Value,
                                               passwordSubject.Value,
                                               termsOfServiceAccepted,
                                               (int)countryId.Value,
                                               timezone)
                                           )
                               .Track(analyticsService.SignUp, AuthenticationMethod.EmailAndPassword)
                               .Subscribe(onDataSource, onError, onCompleted);
        }