Beispiel #1
0
 public bool comparesPasswordComingFromUser_toPasswordInDataBase(string username, string password)
 {
     bool isTheCorrectPassword = false;
     SecurityPassword securityPassword = new SecurityPassword();
     String encryptedPasswordFromDataBase = bringsEncryptedPasswordFromDataBase_underNameOfUser(username);
     String passwordFromUserAferEncryption = securityPassword.Encrypt(password);
     if (encryptedPasswordFromDataBase == passwordFromUserAferEncryption)
     {
         isTheCorrectPassword = true;
     }
     return isTheCorrectPassword;
 }
Beispiel #2
0
        public void createUser(User user)
        {
            SecurityPassword encrPass = new SecurityPassword();
            string password = encrPass.Encrypt(user.Password);
            try
            {
                SqlConnection connection = ManageDatabaseConnection("Open");
                using (SqlCommand sqlCommand = new SqlCommand("Insert_user1", connection))
                {

                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.Parameters.Add("@Username_Email", SqlDbType.VarChar).Value = user.Username;
                    sqlCommand.Parameters.Add("@IdNumber", SqlDbType.Int).Value = user.IdNumber;
                    sqlCommand.Parameters.Add("@Name", SqlDbType.VarChar).Value = user.Name;
                    sqlCommand.Parameters.Add("@MidName", SqlDbType.VarChar).Value = user.SecondName;
                    sqlCommand.Parameters.Add("@Lastname", SqlDbType.VarChar).Value = user.LastName;
                    sqlCommand.Parameters.Add("@SecondLastname", SqlDbType.VarChar).Value = user.SecondName;
                    sqlCommand.Parameters.Add("@Celular", SqlDbType.VarChar).Value = user.Cellphone;
                    sqlCommand.Parameters.Add("@Password_Encr", SqlDbType.VarChar).Value = password;
                    sqlCommand.Parameters.Add("@IdMajor", SqlDbType.Int).Value = user.IdMajor;
                    sqlCommand.Parameters.Add("@IdUserType", SqlDbType.Int).Value = user.Type;
                    sqlCommand.Parameters.Add("@HasCertificate", SqlDbType.Bit).Value = "false";
                    sqlCommand.Parameters.Add("@IsSanctioned", SqlDbType.Bit).Value = "false";

                    //connection.Open();
                    sqlCommand.ExecuteNonQuery();
                    connection = ManageDatabaseConnection("Close");
                }
            }
            catch (SqlException sqlException)
            {
                throw sqlException;
            }
        }