Пример #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();
         }
     }
 }
Пример #3
0
        private void ReLogin(string newWiki)
        {
            buttonSave.Enabled = false;

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

            var newLogin = new WikiLogin(Main.login.Username, Main.login.Password, newWiki);

            if (newLogin.Login() == "Success")
            {
                Main.login = newLogin;
                Main.UpdateTitle();
                Main.GetEditToken();
                Main.AddLogMessage($"Logged in as {newLogin.Username}" + Environment.NewLine);
                Main.UpdateExtensionInfo();
                if (Properties.Settings.Default.AutoLogin)
                {
                    Properties.Settings.Default.Wiki = newWiki;
                    Properties.Settings.Default.Save();
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                ShowError("Couldn't login, try again");
            }
        }