void saveButton_Click(object sender, EventArgs e) { string lift = ""; gymstatDB mydb = new gymstatDB(); switch (LiftSelector.SelectedIndex) { case 0: lift = "squats"; break; case 1: lift = "press"; break; case 2: lift = "deadlift"; break; default: break; } WorkoutIDText.Text = "Submitted that you did set " + setBox.Text + " for " + repBox.Text + " reps at " + weightBox.Text + " doing " + lift; if (mydb.insertWorkout(lift, lastWorkout, setBox.Text, repBox.Text, weightBox.Text)) { WorkoutIDText.Text = "Submitted that you did set " + setBox.Text + " for " + repBox.Text + " reps at " + weightBox.Text + " doing " + lift; } }
protected void Page_Load(object sender, EventArgs e) { string username = crypto.validateCookies(Request.Cookies); saveButton.Click += saveButton_Click; string date = DateTime.Now.ToString("yyyy-MM-dd"); string start = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); welcome.Text = "Welcome " + username + " " + date + " " + start; gymstatDB mydb = new gymstatDB(); if (mydb.startWorkout(username)) { lastWorkout = mydb.getLastWorkoutID(username); if (mydb.startWorkoutA(lastWorkout)) { if (mydb.enterStartTimes(lastWorkout, date, start)) { WorkoutIDText.Text = "Created New Workout with Workout ID: " + lastWorkout + " " + LiftSelector.SelectedIndex.ToString();; } } } else { WorkoutIDText.Text = "Failed to create workout"; } LiftSelector.SelectedIndex.ToString(); }
void logButton_Click(object sender, EventArgs e) { gymstatDB mydb = new gymstatDB(); if (crypto.sha256_hash(passwordText.Text) == mydb.getHashedPassword(usernameText.Text)) { crypto.installCookies(Response.Cookies, usernameText.Text, crypto.sha256_hash(passwordText.Text)); Response.Redirect("LoginSuccess.aspx"); } }
void registerButton_Click(object sender, EventArgs e) { gymstatDB mydb = new gymstatDB(); if (mydb.registerNewUser(usernameText.Text, crypto.sha256_hash(passwordText.Text), crypto.sha256_hash(vpasswordText.Text))) { crypto.installCookies(Response.Cookies, usernameText.Text, crypto.sha256_hash(passwordText.Text)); Response.Redirect("RegisterSuccess.aspx"); } else { usernameText.Text = ""; passwordText.Text = ""; vpasswordText.Text = ""; registerError.Text = "Username already Taken or passwords did not match, Try Again"; } }
internal static bool validateCookies(HttpCookieCollection cook, bool test) { if ((cook["username"] != null) && cook["secureCookie"] != null) { gymstatDB mydb = new gymstatDB(); string username = cook["username"].Value; string hashedpw = mydb.getHashedPassword(username); string trueHashed = crypto.sha256_hash(hashedpw + username); if (cook["secureCookie"].Value == trueHashed) { return(true); } else { return(false); } } else { return(false); } }
internal static string validateCookies(HttpCookieCollection cook) { if ((cook["username"] != null) && cook["secureCookie"] != null) { gymstatDB mydb = new gymstatDB(); crypto mycrypto = new crypto(); string username = cook["username"].Value; string hashedpw = mydb.getHashedPassword(username); string trueHashed = crypto.sha256_hash(hashedpw + username); if (cook["secureCookie"].Value.StartsWith(trueHashed)) { return(username); } else { return(""); } } else { return(""); } }