Ejemplo n.º 1
0
        private async void CreateAccount()
        {
            var mail = new Email()
            {
                email = email
            };

            account.password = Convert.ToBase64String(Encoding.UTF8.GetBytes(account.password));
            account.password = Encrypt(account.password);
            var task     = signup.accounts.InsertOneAsync(account);
            var task1    = signup.emails.InsertOneAsync(mail);
            var roomJoin = new Room_Join()
            {
                account = account, database = signup.database, client = signup.client, accounts = signup.accounts
            };

            roomJoin.Closed += (s, args) => this.Close();
            await task;
            await task1;

            success = true;
            timer1.Stop();
            this.Hide();
            roomJoin.Show();
        }
Ejemplo n.º 2
0
        private async void LoginAccount()
        {
            if (string.IsNullOrWhiteSpace(usernameBox.Text) || string.IsNullOrWhiteSpace(passwordBox.Text))
            {
                MessageBox.Show("Please fill in the missing username or password", "Missing information");
            }
            else if (passwordBox.Text.Contains(' ') || passwordBox.Text.Length < 6)
            {
                MessageBox.Show("Your password is invalid, please re-type your password", "Invalid password");
                return;
            }
            else if (usernameBox.Text.Contains(' '))
            {
                MessageBox.Show("Your username is invalid, please re-type your username", "Invalid username");
                return;
            }
            else
            {
                var myAcc = accounts.Find(s => s.username == usernameBox.Text).FirstOrDefault();
                if (myAcc == null)
                {
                    MessageBox.Show("Your username does not exist", "Incorrect username");
                }
                else if (myAcc.password != Encrypt(Convert.ToBase64String(Encoding.UTF8.GetBytes(passwordBox.Text))))
                {
                    MessageBox.Show("Your password is incorrect", "Incorrect password");
                }
                else
                {
                    if (myAcc.connected)
                    {
                        MessageBox.Show("Your account is currently online, you cannot log into a currently online account", "Currently online account");
                    }
                    else
                    {
                        var filter = Builders <Account> .Filter.Eq("_id", myAcc.username);

                        var updateConnection = Builders <Account> .Update.Set("connected", true);

                        var task = accounts.UpdateOneAsync(filter, updateConnection);
                        myAcc.connected = true;
                        var roomJoin = new Room_Join()
                        {
                            account = myAcc, database = database, client = client, accounts = accounts
                        };
                        roomJoin.Closed += (s, args) => this.Reload();
                        await task;
                        this.Hide();
                        roomJoin.Show();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void LogIn()
        {
            var roomJoin = new Room_Join()
            {
                account = account, database = signin.database, client = signin.client, accounts = signin.accounts
            };

            roomJoin.Closed += (s, args) => this.Close();
            timer1.Stop();
            this.Hide();
            roomJoin.Show();
        }