コード例 #1
0
ファイル: MainForm.cs プロジェクト: jgabrielius/komanda1
 private void ChangePassword_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(currentPassword.Text) ||
         String.IsNullOrEmpty(newPassword.Text) || String.IsNullOrEmpty(newPassword2.Text))
     {
         MessageBox.Show(Messages.emptyFields);
         Logger.Log(Messages.emptyFields);
     }
     else
     {
         if (newPassword.Text.Length >= 6 && newPassword2.Text.Length >= 6)
         {
             new UserEditingService(currentUser)
             .UpdateSetting("password", PasswordHasher.CreateMD5(currentPassword.Text),
                            PasswordHasher.CreateMD5(newPassword.Text), PasswordHasher.CreateMD5(newPassword2.Text),
                            Messages.newPasswordSameAsOld, Messages.passwordUpdateSuccess,
                            Messages.passwordUpdateFailed, Messages.passwordsDoNotMatch, Messages.passwordIncorrect);
             ClearValues();
         }
         else
         {
             MessageBox.Show(Messages.passwordTooShort);
             Logger.Log(Messages.passwordTooShort);
         }
     }
 }
コード例 #2
0
ファイル: LoginForm.cs プロジェクト: jgabrielius/komanda1
        private bool ValidateFields(string username, string password)
        {
            var hashedPassword   = PasswordHasher.CreateMD5(password);
            var credentialResult = SqlDriver.Fetch($"SELECT username, password FROM users WHERE username='******' AND password='******';");

            return(credentialResult != null && credentialResult.Count == 1);
        }
コード例 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="pId"></param>
 /// <param name="pContrasenia"></param>
 public Usuario(string pId, string pContrasenia)
 {
     Id          = pId;
     Contrasenia = PasswordHasher.CreateMD5
                       (pContrasenia);
     Administrador = false;
 }
コード例 #4
0
        private void UpdatePassword(string newPassword, string username)
        {
            var sqlUpdatePassword = "******" +
                                    PasswordHasher.CreateMD5(newPassword) +
                                    "' WHERE username='******';";

            try
            {
                if (SqlDriver.Execute(sqlUpdatePassword))
                {
                    Logger.Log(Messages.passwordUpdateSuccess);
                }
                else
                {
                    Logger.Log(Messages.passwordUpdateFailed);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
            }
        }
コード例 #5
0
ファイル: SignupForm.cs プロジェクト: jgabrielius/komanda1
        private void CreateAccountButton_Click(object sender, EventArgs e)
        {
            if (ValidateFields())
            {
                var newUser = new UserModel()
                {
                    Username   = usernameText.Text,
                    FirstName  = firstNameText.Text,
                    LastName   = lastNameText.Text,
                    Email      = emailText.Text,
                    University = universityBox.SelectedItem.ToString(),
                    Status     = statusBox.SelectedItem.ToString(),
                    Password   = PasswordHasher.CreateMD5(passwordText.Text),
                };
                SendUserToDb(newUser);

                Hide();
                var loginForm = new LoginForm();
                loginForm.Closed += (s, args) => this.Close();
                loginForm.ShowDialog();
            }
        }