예제 #1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            Username = textBoxUsername.Text;
            Password = textBoxPassword.Text;
            Wiki     = textBoxSite.Text;

            if (string.IsNullOrWhiteSpace(Username))
            {
                ShowError("Username can not be empty");
                return;
            }
            if (string.IsNullOrWhiteSpace(Password))
            {
                ShowError("Password can not be empty");
                return;
            }

            if (!Wiki.EndsWith(".wikia.com") && !Wiki.EndsWith(".fandom.com"))
            {
                ShowError("Invalid domain");
                return;
            }
            if (!Wiki.StartsWith("http://") && !Wiki.StartsWith("https://"))
            {
                Wiki = "https://" + Wiki;
            }

            login = new WikiLogin(Username, Password, Wiki);

            if (checkBoxSaveCreds.Checked)
            {
                Properties.Settings.Default.Username  = Username;
                Properties.Settings.Default.Password  = Password;
                Properties.Settings.Default.Wiki      = Wiki;
                Properties.Settings.Default.AutoLogin = true;
                Properties.Settings.Default.Save();
            }

            buttonLogin.Enabled = false;
            buttonLogin.Text    = "Logging in...";
            bool isAutoConfirmed = login.IsUserAutoConfirmed();

            if (!isAutoConfirmed)
            {
                ShowError("Account is not autoconfirmed");
                return;
            }

            string loginResult = login.Login();

            if (loginResult == "Success")
            {
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                ShowError("Couldn't login, try again");
            }
        }
예제 #2
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (Properties.Settings.Default.AutoLogin)
     {
         login = new WikiLogin(Properties.Settings.Default.Username,
                               Properties.Settings.Default.Password,
                               Properties.Settings.Default.Wiki);
         if (!login.IsUserAutoConfirmed() || login.Login() != "Success")
         {
             LoginForm loginForm = new LoginForm();
             loginForm.FillIn(login.Username, login.Password, login.Wiki);
             if (loginForm.ShowDialog() == DialogResult.OK)
             {
                 login = loginForm.login;
             }
             else
             {
                 Close();
                 return;
             }
         }
         UpdateTitle();
         GetEditToken();
         AddLogMessage($"Logged in as {login.Username}" + Environment.NewLine);
         UpdateExtensionInfo();
     }
     else
     {
         LoginForm loginForm = new LoginForm();
         if (loginForm.ShowDialog() == DialogResult.OK)
         {
             login = loginForm.login;
             UpdateTitle();
             GetEditToken();
             AddLogMessage($"Logged in as {login.Username}" + Environment.NewLine);
             UpdateExtensionInfo();
         }
         else
         {
             Close();
         }
     }
 }