async Task googleLogin()
        {
            try
            {
                UserCredential credential;
                credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    new ClientSecrets
                {
                    ClientId     = "426090949585-uj7lka2mtanjgd7j9i6c4ik091rcv6n5.apps.googleusercontent.com",
                    ClientSecret = "6IHWKIfTAMF7cPJsBvoGxYui"
                },
                    new[] {
                    Oauth2Service.Scope.UserinfoEmail,
                    Oauth2Service.Scope.UserinfoProfile
                },
                    "user",
                    CancellationToken.None,
                    null);

                Toggl.GoogleLogin(credential.Token.AccessToken);
                await credential.RevokeTokenAsync(CancellationToken.None);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerException != null &&
                    ex.InnerException.Message.Contains("access_denied"))
                {
                    Toggl.NewError("Login process was canceled", true);
                }
                else
                {
                    Toggl.NewError(ex.Message, false);
                }
            }
        }
Beispiel #2
0
        private bool validateFields()
        {
            if (this.emailTextBox.Text == "")
            {
                this.emailTextBox.Focus();
                Toggl.NewError("Please enter valid email address", true);
                return(false);
            }
            if (this.passwordBox.Text == "")
            {
                this.passwordBox.Focus();
                Toggl.NewError("A password is required", true);
                return(false);
            }

            if (this.confirmAction == ConfirmAction.SignUp)
            {
                if (this.selectedCountryID == -1)
                {
                    this.countrySelect.Focus();
                    Toggl.NewError("Please select Country before signing up", true);
                    return(false);
                }
                if (!this.tosCheckbox.IsChecked.Value)
                {
                    this.tosCheckbox.Focus();
                    Toggl.NewError("You must agree to the terms of service and privacy policy to use Toggl", true);

                    return(false);
                }
            }
            return(true);
        }
Beispiel #3
0
        private bool validateMandatorySignupFields()
        {
            if (this.selectedCountryID == -1)
            {
                this.countrySelect.Focus();
                Toggl.NewError("Please select Country before signing up", true);
                return(false);
            }
            if (!this.tosCheckbox.IsChecked.Value)
            {
                this.tosCheckbox.Focus();
                Toggl.NewError("You must agree to the terms of service and privacy policy to use Toggl", true);

                return(false);
            }

            return(true);
        }
Beispiel #4
0
        private async void googleSignup()
        {
            try
            {
                var credential = await obtainGoogleUserCredentialAsync();

                Toggl.GoogleSignup(credential.Token.AccessToken, selectedCountryID);
                await credential.RevokeTokenAsync(CancellationToken.None);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("access_denied") ||
                    (ex.InnerException != null &&
                     ex.InnerException.Message.Contains("access_denied")))
                {
                    Toggl.NewError("Signup process was canceled", true);
                }
                else
                {
                    Toggl.NewError(ex.Message, false);
                }
            }
        }
Beispiel #5
0
        private bool validateLoginSignup()
        {
            if (this.emailTextBox.Text == "")
            {
                this.emailTextBox.Focus();
                Toggl.NewError("Please enter valid email address", true);
                return(false);
            }
            if (this.passwordBox.Text == "")
            {
                this.passwordBox.Focus();
                Toggl.NewError("A password is required", true);
                return(false);
            }

            if (this.confirmAction == ConfirmAction.SignUp &&
                !validateMandatorySignupFields())
            {
                return(false);
            }

            return(true);
        }