protected void Register_User(string addr1, string addr2, string city, string region, string country, string postcode, string username, string password, string email, string phoneno, string firstname, string lastname) { //STEP 1: Get Hash/Salt for password Auth.AuthData authdata = Auth.StringToHashSalt(password); //STEP 2: (Optional) Attempt to get coords for address string coordsX = "0"; string coordsY = "0"; //STEP 3: Register! try { DataSetTableAdapters.QueriesTableAdapter querytableadapter = new DataSetTableAdapters.QueriesTableAdapter(); querytableadapter.RegisterUser(addr1, addr2, city, region, country, postcode, coordsX, coordsY, true, username, authdata.Hash, authdata.Salt, email, phoneno, firstname, lastname, true); } catch (Exception exc) { if (exc.Message.Contains("Cannot insert duplicate key in object 'dbo.Users'")) { Alert_Composer("alert-danger", "Could not register account!", "Username already exists. Try another one."); } return; } //STEP 4: Send a confirmation email Common.Email.SendEmail(textBoxEmail.Text, "Thank you for joining QACinemas", String.Format("{0} {1}, {2} registered.", textBoxFirstN.Text, textBoxLastN.Text, textBoxUsername.Text)); Response.Redirect("/Login.aspx?alert=4&username=" + textBoxUsername.Text); }
public void GenerateHashSaltFromPassword() { TEST_AUTHDATA = Auth.StringToHashSalt(TEST_PASSWORD); Debug.WriteLine(String.Format("Password = {0}, Hash = {1}, Salt = {2}", TEST_PASSWORD, TEST_AUTHDATA.Hash, TEST_AUTHDATA.Salt)); Assert.IsTrue(TEST_AUTHDATA != null && !String.IsNullOrEmpty(TEST_AUTHDATA.Hash) && !String.IsNullOrEmpty(TEST_AUTHDATA.Salt), String.Format("Password = {0}, Hash = {1}, Salt = {2}", TEST_PASSWORD, TEST_AUTHDATA.Hash, TEST_AUTHDATA.Salt)); }