public LoginWindow(APIControl apiControl)
        {
            InitializeComponent();

            this.apiControl = apiControl;

            if (Properties.Settings.Default.username != "" && Properties.Settings.Default.password != "")
            {
                emailTextBox.Text    = Properties.Settings.Default.username;
                passwordBox.Password = DPAPIInterface.Unprotect(Properties.Settings.Default.password, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);

                passwordConfirmHide(true);
                signInButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }
            else if (Properties.Settings.Default.username != "")
            {
                emailTextBox.Text = Properties.Settings.Default.username;

                passwordConfirmHide(true);
                signInButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }
            else
            {
                passwordConfirmHide(false);
                signUpButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }

            initialClick = true;
            submitButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
        }
Esempio n. 2
0
        public bool checkStoredLogin()
        {
            string username = Properties.Settings.Default.username;
            string password = Properties.Settings.Default.password;

            if (password != "")
            {
                password = DPAPIInterface.Unprotect(password, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
            }

            if (password == "" || username == "")
            {
                return(false);
            }

            try
            {
                if (signIn(username, password) == SignInResponse.SignedIn)
                {
                    var getKeyResponse = getKey();

                    if (getKeyResponse.Result.StatusCode == HttpStatusCode.OK)
                    {
                        var getKeyResponseString = getKeyResponse.Result.Content.ReadAsStringAsync();
                        var getKeyDict           = JsonConvert.DeserializeObject <Dictionary <string, string> >(getKeyResponseString.Result);

                        if (!getKeyDict.ContainsKey("code"))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (AggregateException e)
            {
                throw e;
            }
        }