예제 #1
0
        /*Marcus page*/
        private void RedirectMarcusHome(object sender, RoutedEventArgs e)
        {
            ReadConfigFile();//Marcus's config file 
            //check if user set a password for SecLogin
            if (ConfigPass.Equals("n"))
            {
                //pw not set 
                ContentWrapper.NavigationService.Navigate(new MarcusHome());
            }
            else 
            {
                //user has password set
                string passwordPromptBox = new InputBox("\nEnter Password").ShowDialog();

                if (passwordPromptBox.Equals(ConfigPass))//password match 
                {
                    ContentWrapper.NavigationService.Navigate(new MarcusHome());
                }
                else
                {
                    MessageBox.Show("Wrong password!");//password not match
                    passcount += 1;
                    if (passcount == 2)
                    {
                        string sMessageBoxText = "Do you want to reset your password??";
                        string sCaption = "Multiple failed password attempts";

                        MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
                        MessageBoxImage icnMessageBox = MessageBoxImage.Warning;

                        MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                        switch (rsltMessageBox)
                        {
                            case MessageBoxResult.Yes:
                                /* ... */
                                MarcusTwilio msg = new MarcusTwilio();
                                msg.calltwilio(ConfigPhoneNo, "A reset for your password was requested." +ConfigPass);
                                MessageBox.Show("A reset has been sent to your SMS / Email");
                                passcount = 0;
                                break;

                            case MessageBoxResult.No:
                                /* ... */
                                break;

                        }

                        passcount = 0;
                    }
                }
            }

        }
예제 #2
0
        }//only called ONCE on visiting page

        //set new password
        private void SetPassword(object sender, RoutedEventArgs e)
        {
            ReadConfigFile();
            if (ConfigPassword.Equals("n"))
            {
                string passwordPromptBox = new InputBox("\nSet a new password").ShowDialog();
                if (passwordPromptBox.Length < 8)
                {
                    MessageBox.Show("password can't be less than 8 characters!");
                }
                else
                {
                    WriteConfigPassword(passwordPromptBox);
                    MessageBox.Show("Password set!");
                    ReadConfigFile();
                    GetMyCurrentConfig();
                }
            }
            else
            {
                //prompt for previous password
                //if match, allow
                //else dont
                string passwordPromptBox = new InputBox("\nEnter EXISTING password").ShowDialog();
                if (passwordPromptBox.Equals(ConfigPassword))
                {
                    //if match, ask for new password
                    string updatedPasswordPrompt = new InputBox("\nEnter NEW password").ShowDialog();
                    if (updatedPasswordPrompt.Equals("") || updatedPasswordPrompt.Length < 8)
                    {
                        MessageBox.Show("Password NOT updated. It can't be blank or less than 8 characters");
                    }
                    else
                    {
                        WriteConfigPassword(updatedPasswordPrompt);
                        MessageBox.Show("Password Updated!");
                        ReadConfigFile();
                        GetMyCurrentConfig();
                    }
                }
                else
                {
                    MessageBox.Show("Wrong password");
                }
            }
        }
예제 #3
0
        //remove password
        private void RemovePassword(object sender, RoutedEventArgs e)
        {
            ReadConfigFile();
            if (ConfigPassword.Equals("n"))
            {
                MessageBox.Show("You haven't set a password, nothing to remove leh.");
            }
            else
            {
                string passwordPromptBox = new InputBox("\nEnter Current Password").ShowDialog();
                if (passwordPromptBox.Equals(ConfigPassword))
                {
                    string sMessageBoxText = "Do you want to remove your password? (we don't recommend this!)";
                    string sCaption        = "Password removal";

                    MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
                    MessageBoxImage  icnMessageBox = MessageBoxImage.Warning;

                    MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                    switch (rsltMessageBox)
                    {
                    case MessageBoxResult.Yes:
                        /* ... */
                        WriteConfigPassword("n");
                        MessageBox.Show("Password has been REMOVED");
                        break;

                    case MessageBoxResult.No:
                        /* ... */
                        MessageBox.Show("No changes made");
                        break;
                    }
                }
            }

            ReadConfigFile();
            GetMyCurrentConfig();
        }