コード例 #1
0
        private void BtnAddUser_Click(object sender, EventArgs e)
        {
            string username = new PromptDialog().ShowPrompt("Acadiverse Admin Panel", "Which username are you adding?");

            if (Globals.ShowConfirmationMessage("Are you sure you wish to add the user \"" + username + "\" to the \"" + selectedUserRole.RoleName + "\" user role? This will give them some privileges exclusive to that role and also make some asthetic changes to their profile!", true))
            {
                if (Account.AccountExists(username))
                {
                    if (!selectedUserRole.AssociatedUsers.Contains(Account.LoadFromServer(username).ID))
                    {
                        selectedUserRole.AssociatedUsers.Add(Account.LoadFromServer(username).ID);
                        selectedUserRole.SaveToServer();
                        foreach (BsonObjectId id in selectedUserRole.AssociatedUsers)
                        {
                            lstAssociatedUsers.Items.Add(Account.LoadFromServer(id).Username);
                        }
                    }
                    else
                    {
                        Globals.ShowErrorMessage("This user is already in the selected user role.");
                    }
                }
                else
                {
                    Globals.ShowErrorMessage("This user does not exist.");
                }
            }
        }
コード例 #2
0
 private void FrmProfile_Load(object sender, EventArgs e)
 {
     if (Account.AccountExists(username))
     {
         currentAccount = Account.LoadFromServer(username);
         if (currentAccount.AccountBanned)
         {
             pnlProfileErrorOverlay.Show();
             lblProfileError.Text  = "This account is banned.";
             picProfileImage.Image = MagiZile.Acadiverse.Properties.Resources.img_profile_banned_user;
         }
         else
         {
             pnlProfileErrorOverlay.Hide();
             picProfileImage.Image       = currentAccount.ProfileImage;
             lblDisplayName.Text         = currentAccount.DisplayName;
             lblProfileBio.Text          = currentAccount.ProfileBio;
             lblBirthday.Text            = currentAccount.Birthday.ToString();
             lblAccountCreationDate.Text = currentAccount.AccountCreationDate.ToString();
             lblLastLoginDate.Text       = currentAccount.LastLoginDate.ToString();
             pnlModeratorOptions.Visible = UserRole.UserHasRole(currentAccount, "moderators");
         }
     }
     else
     {
         pnlProfileErrorOverlay.Show();
         lblProfileError.Text = MagiZile.Acadiverse.Properties.Resources.str_incorrect_username;
     }
     if (editingProfile)
     {
         btnSaveChanges.Show();
         btnBlock.Hide();
         btnAddBuddy.Hide();
         btnSendPM.Hide();
         lblDisplayName.Hide();
         txtDisplayName.Show();
         txtProfileBio.BorderStyle = BorderStyle.FixedSingle;
         txtProfileBio.ReadOnly    = false;
         pnlModeratorOptions.Hide();
     }
 }
コード例 #3
0
 private void btnCreateAccount_Click(object sender, RoutedEventArgs e)
 {
     if (Account.AccountExists(txtRegisterUsername.Text))
     {
         ShowErrorText(lblRegistrationError, "This username is unavailable.");
         return;
     }
     else
     {
         bool disallowedUsername = wordFilter.ContainsBadWords(txtRegisterUsername.Text, false);
         if (disallowedUsername)
         {
             ShowErrorText(lblRegistrationError, "The username you have chosen is not allowed on Acadiverse because it contains swear words or racial slurs.");
             return;
         }
         else
         {
             if (pwdRegisterPassword.Password == pwdConfirmPassword.Password)
             {
                 if (PasswordStrength() == -1)
                 {
                     MessageBox.Show("Your password does not meet the requirements.");
                     return;
                 }
                 else
                 {
                     if (dtpBirthday.SelectedDate == null)
                     {
                         ShowErrorText(lblRegistrationError, "Please enter a valid birthday.");
                         return;
                     }
                     else
                     {
                         if (txtRegisterEmail.Text == "")
                         {
                             ShowErrorText(lblRegistrationError, "The email must not be blank.");
                             return;
                         }
                         else
                         {
                             if (!radParent.IsChecked.Value == true && !radStudent.IsChecked.Value == true && !radTeacher.IsChecked.Value == true)
                             {
                                 ShowErrorText(lblRegistrationError, "Please select an account type.");
                                 return;
                             }
                             else
                             {
                                 if (!chkAgreeToPolicies.IsChecked.Value == true)
                                 {
                                     ShowErrorText(lblRegistrationError, "You must agree to the Terms of Secrive, Code of Conduct, and Privacy Policy.");
                                     return;
                                 }
                                 else
                                 {
                                     Account account = new Account
                                     {
                                         Username = txtRegisterUsername.Text,
                                         Password = Globals.SaltedPassword(pwdRegisterPassword.Password)
                                     };
                                     if (radParent.IsChecked.Value == true)
                                     {
                                         account.AccountType = AcadiverseAccountType.Parent;
                                     }
                                     else if (radStudent.IsChecked.Value == true)
                                     {
                                         account.AccountType = AcadiverseAccountType.Student;
                                     }
                                     else if (radTeacher.IsChecked.Value == true)
                                     {
                                         account.AccountType = AcadiverseAccountType.Teacher;
                                     }
                                     else
                                     {
                                         throw (new InvalidOperationException());
                                     }
                                     account.AccountBanned       = false;
                                     account.DateBanExpires      = new DateTime(1970, 1, 1);
                                     account.BanReason           = "";
                                     account.CanPublish          = true;
                                     account.CanChat             = true;
                                     account.Birthday            = dtpBirthday.SelectedDate.Value;
                                     account.ProfileBio          = "";
                                     account.ReputationPoints    = 0;
                                     account.Money               = 0;
                                     account.LastLoginDate       = DateTime.Now;
                                     account.AccountCreationDate = DateTime.Now;
                                     account.Buddies             = new BsonArray();
                                     account.PrivateMessages     = new BsonArray();
                                     account.Email               = txtRegisterEmail.Text;
                                     account.SaveToServer();
                                     currentAccount         = account;
                                     stkRegister.Visibility = Visibility.Hidden;
                                     Login(true);
                                 }
                             }
                         }
                     }
                 }
             }
             else
             {
                 ShowErrorText(lblRegistrationError, "The passwords do not match.");
                 return;
             }
         }
     }
 }
コード例 #4
0
        void Login(bool newAccount)
        {
            Account objAccount = null;

            try
            {
                if (newAccount)
                {
                    objAccount = Account.LoadFromServer(currentAccount.Username);
                    goto FinishLogin;
                }
                else
                {
                    if (txtUsername.Text != "")
                    {
                        if (Account.AccountExists(txtUsername.Text))
                        {
                            objAccount = Account.LoadFromServer(txtUsername.Text);
                        }
                        else
                        {
                            ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_incorrect_username);
                            return;
                        }
                        if (pwdPassword.Password == "")
                        {
                            ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_blank_password);
                            return;
                        }
                        else
                        {
                            if (Globals.CorrectPassword(pwdPassword.Password, objAccount.Password) == false)
                            {
                                ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_incorrect_password);
                                return;
                            }
                            else
                            {
                                if (objAccount.AccountBanned)
                                {
                                    if (objAccount.DateBanExpires.Year == 1970)
                                    {
                                        ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_account_permabanned.Replace("$1", objAccount.BanReason));
                                        return;
                                    }
                                    else
                                    {
                                        ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_account_tempbanned.Replace("$1", objAccount.DateBanExpires.ToLongDateString()).Replace("$2", objAccount.BanReason));
                                        return;
                                    }
                                }
                                else
                                {
                                    goto FinishLogin;
                                }
                            }
                        }
                    }
                    else
                    {
                        ShowErrorText(lblLoginError, MagiZile.Acadiverse.Properties.Resources.str_blank_username);
                        return;
                    }
                }
            }
            catch (DnsClient.DnsResponseException)
            {
                StopDataUpdateThread();
                ShowOverlay("Connection Error", MagiZile.Acadiverse.Properties.Resources.str_connection_error, "OK", "");
                InitDataUpdateThread();
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (ArgumentOutOfRangeException)
            {
                ShowOverlay("Connection Error", MagiZile.Acadiverse.Properties.Resources.str_connection_error, "OK", "");
                return;
            }
#pragma warning restore CA1031 // Do not catch general exception types
            catch (TimeoutException)
            {
                ShowOverlay("Connection Error", "The connection timed out. Please check your firewall settings to see if Acadiverse Desktop Client for Windows is blocked. Don't worry; all Acadiverse programs are safe!", "OK", "");
                return;
            }
FinishLogin:
            currentAccount                = objAccount;
            stkLogin.Visibility           = Visibility.Collapsed;
            tabChats.Visibility           = Visibility.Visible;
            tabSubmissions.Visibility     = Visibility.Visible;
            tabAcadiverseStore.Visibility = Visibility.Visible;
            grdTop.Visibility             = Visibility.Visible;
            grdMain.Visibility            = Visibility.Visible;
            grdBottom.Visibility          = Visibility.Visible;
            lblUsername.Content           = currentAccount.DisplayName + " (@" + currentAccount.Username + ")";
            lblReputationPoints.Content   = currentAccount.ReputationPoints.ToString() + " Reputation Points";
            lblMoney.Content              = currentAccount.Money + " Acadicions";
            if (currentAccount.ProfileImage == null)
            {
                picProfileImage.Source = new BitmapImage(new Uri("http://acadiverse.magizile.com/images/img_profile_default.bmp"));
            }
            else
            {
                currentAccount.ProfileImage.Save("profile.bmp");
                picProfileImage.Source = new BitmapImage(new Uri("profile.bmp"));
                File.Delete("profile.bmp");
            }
            currentAccount.LastLoginDate = DateTime.Now;
            currentAccount.SaveToServer();
            InitDataUpdateThread();
        }
コード例 #5
0
 void Login()
 {
     if (txtUsername.Text != "")
     {
         Account objAccount;
         if (Account.AccountExists(txtUsername.Text))
         {
             objAccount = Account.LoadFromServer(txtUsername.Text);
         }
         else
         {
             Show();
             chkKeepUserLoggedIn.Checked = false;
             Globals.ShowErrorMessage(Resources.str_incorrect_username);
             return;
         }
         if (txtPassword.Text == "")
         {
             Show();
             chkKeepUserLoggedIn.Checked = false;
             Globals.ShowErrorMessage(Resources.str_blank_password);
         }
         else
         {
             if (txtPassword.Text != Globals.DecryptString(objAccount.Password))
             {
                 Show();
                 chkKeepUserLoggedIn.Checked = false;
                 Globals.ShowErrorMessage(Resources.str_incorrect_passwrod);
             }
             else
             {
                 if (objAccount.AccountBanned)
                 {
                     Show();
                     chkKeepUserLoggedIn.Checked = false;
                     if (objAccount.DateBanExpires.Year == 1970)
                     {
                         new TaskDialog
                         {
                             Caption           = "Account Banned",
                             InstructionText   = "Your account has been banned.",
                             Text              = Resources.str_account_permabanned.Replace("$1", objAccount.BanReason),
                             HyperlinksEnabled = true
                         }.Show();
                     }
                     else
                     {
                         new TaskDialog
                         {
                             Caption           = "Account Banned",
                             InstructionText   = "Your account has been banned.",
                             Text              = Resources.str_account_tempbanned.Replace("$1", objAccount.DateBanExpires.ToLongDateString()).Replace("$2", objAccount.BanReason),
                             HyperlinksEnabled = true
                         }.Show();
                     }
                 }
                 else
                 {
                     if (chkKeepUserLoggedIn.Checked)
                     {
                         Registry.SetValue(Globals.REGISTRY_PATH + @"\Acadiverse Desktop Client for Windows", "SaveLoginDetails", true);
                         Registry.SetValue(Globals.REGISTRY_PATH + @"\Acadiverse Desktop Client for Windows", "CurrentUsername", txtUsername.Text);
                         Registry.SetValue(Globals.REGISTRY_PATH + @"\Acadiverse Desktop Client for Windows", "CurrentPassword", Globals.EncryptString(txtPassword.Text));
                     }
                     currentAccount    = objAccount;
                     this.DialogResult = DialogResult.OK;
                 }
             }
         }
     }
     else
     {
         Globals.ShowErrorMessage(Resources.str_blank_username);
     }
 }
コード例 #6
0
 private void BtnRegister_Click(object sender, EventArgs e)
 {
     if (Account.AccountExists(txtUsername.Text))
     {
         Globals.ShowErrorMessage("This username is unavailable.");
     }
     else
     {
         if (new WordFilter(WordFilter.FilteringLevel.Strict).ContainsBadWords(txtUsername.Text, false))
         {
             Globals.ShowErrorMessage("The username you have chosen is not allowed on Acadiverse because it contains swear words or racial slurs.");
         }
         else
         {
             if (txtPassword.Text == txtConfirmPassword.Text)
             {
                 if (PasswordStrength() == -1)
                 {
                     MessageBox.Show("Your password does not meet the requirements.");
                 }
                 else
                 {
                     if (mtxBirthday.Text == "")
                     {
                         Globals.ShowErrorMessage("Please enter a valid birthday.");
                     }
                     else
                     {
                         if (txtEmail.Text == "")
                         {
                             Globals.ShowErrorMessage("The email must not be blank.");
                         }
                         else
                         {
                             if (!rbtParent.Checked && !rbtStudent.Checked && !rbtTeacher.Checked)
                             {
                                 Globals.ShowErrorMessage("Please select an account type.");
                             }
                             else
                             {
                                 if (!chkAgreeToPolicies.Checked)
                                 {
                                     Globals.ShowErrorMessage("You must agree to the Terms of Secrive, Code of Conduct, and Privacy Policy.");
                                 }
                                 else
                                 {
                                     Account account = new Account
                                     {
                                         Username = txtUsername.Text,
                                         Password = Globals.EncryptString(txtPassword.Text)
                                     };
                                     if (rbtParent.Checked)
                                     {
                                         account.AccountType = AcadiverseAccountType.Parent;
                                     }
                                     else if (rbtStudent.Checked)
                                     {
                                         account.AccountType = AcadiverseAccountType.Student;
                                     }
                                     else if (rbtTeacher.Checked)
                                     {
                                         account.AccountType = AcadiverseAccountType.Teacher;
                                     }
                                     else
                                     {
                                         throw (new InvalidOperationException());
                                     }
                                     account.AccountBanned       = false;
                                     account.DateBanExpires      = new DateTime(1970, 1, 1);
                                     account.BanReason           = "";
                                     account.CanPublish          = true;
                                     account.CanChat             = true;
                                     account.Birthday            = (DateTime)(mtxBirthday.ValidateText());
                                     account.ProfileBio          = "";
                                     account.ReputationPoints    = 0;
                                     account.Money               = 0;
                                     account.LastLoginDate       = DateTime.Now;
                                     account.AccountCreationDate = DateTime.Now;
                                     account.Buddies             = new BsonArray();
                                     account.PrivateMessages     = new BsonArray();
                                     account.Email               = txtEmail.Text;
                                     account.SaveToServer();
                                     newAccount   = account;
                                     DialogResult = DialogResult.OK;
                                     Close();
                                 }
                             }
                         }
                     }
                 }
             }
             else
             {
             }
         }
     }
 }