Beispiel #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            String username = txtLogin.Text;
            String password = txtPassword.Text;

            txtLogin.Enabled    = false;
            txtPassword.Enabled = false;

            if (!String.IsNullOrWhiteSpace(username) || !String.IsNullOrWhiteSpace(password))
            {
                String  hashed  = BCryptHelper.HashPassword(password, BCryptHelper.GenerateSalt());
                Account account = new Account(username, hashed);

                if (!DefaultAccountService.createAccount(username, account))
                {
                    MessageBox.Show("Register failed, username taken.");
                }
                else
                {
                    MessageBox.Show("Register succeeded.");
                }
            }
            else
            {
                MessageBox.Show("Invalid inputs!");
            }

            txtLogin.Enabled    = true;
            txtPassword.Enabled = true;
            txtPassword.Clear();
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String username = txtLogin.Text;
            String password = txtPassword.Text;

            txtLogin.Enabled    = false;
            txtPassword.Enabled = false;

            if (!String.IsNullOrWhiteSpace(username) || !String.IsNullOrWhiteSpace(password))
            {
                AccountService.LoginReply reply = DefaultAccountService.tryLogin(username, password);

                if (reply == AccountService.LoginReply.OK)
                {
                    Account account = DefaultAccountService.getAccount(username);
                    Dex     dex     = new Dex(account, DefaultPokemonService);

                    dex.Show();
                    this.Hide();
                    return;
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password");
                }
            }
            else
            {
                MessageBox.Show("Invalid inputs!");
            }

            txtLogin.Enabled    = true;
            txtPassword.Enabled = true;
            txtPassword.Clear();
        }