//This varia //public bool UserRegistration(User user) //{ // bool IsSuccessful = false; // string sqlregistration = @"Insert into users(username, password, email) Values(@userName, @passWord, @email)"; // using (SqlConnection conn = new SqlConnection(connectionString)) // { // conn.Open(); // SqlCommand cmd = new SqlCommand(sqlregistration, conn); // cmd.Parameters.AddWithValue("@userName", user.UserName); // cmd.Parameters.AddWithValue("@passWord", user.Password); // cmd.Parameters.AddWithValue("@email", user.EmailAddress); // IsSuccessful = (cmd.ExecuteNonQuery() > 0); // } // PwordHash p = new PwordHash(); // p.GenerateSHA256Hash("", ""); // return IsSuccessful; //} public bool UserRegistration(User user) { bool IsSuccessful = false; PwordHash p = new PwordHash(); string hashed = p.SQLSaltHashStore(user.Password); string sqlregistration = @"Insert into users(username, slowhashsalt, email) Values(@userName, @slowhashsalt, @email)"; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(sqlregistration, conn); cmd.Parameters.AddWithValue("@userName", user.UserName); cmd.Parameters.AddWithValue("@slowhashsalt", hashed); cmd.Parameters.AddWithValue("@email", user.EmailAddress); IsSuccessful = (cmd.ExecuteNonQuery() > 0); } return(IsSuccessful); }
public bool AddNewBrewer(string username, string password, bool isBrewer, int breweryID, string email) { string sql = "INSERT INTO users values (@email, @username, @slowhashsalt, @isBrewer, @breweryID, @admin)"; PwordHash p = new PwordHash(); string hashed = p.SQLSaltHashStore(password); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql + _getLastIdSQL, conn); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@slowhashsalt", hashed); cmd.Parameters.AddWithValue("@isBrewer", isBrewer); cmd.Parameters.AddWithValue("@breweryID", breweryID); cmd.Parameters.AddWithValue("@email", email); cmd.Parameters.AddWithValue("@admin", false); int brewID = (int)cmd.ExecuteScalar(); } return(true); }