public static IsValidSecurityCode ( String str ) : bool | ||
str | String | |
Résultat | bool |
private void btnChangeSecurity_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtspassword.Text) == true || string.IsNullOrEmpty(txtncode.Text.Trim()) == true) { Utilities.notifyThem(ntfC, "All fields are necessary", NotificationBox.Type.Error); } else if (!Globals.logUser.pass.Equals(Utilities.MD5Hash(txtspassword.Text))) { Utilities.notifyThem(ntfC, "Wrong Password", NotificationBox.Type.Error); } else if (txtncode.Text.Length < 4) { Utilities.notifyThem(ntfC, "Security code must be at least 4 characters", NotificationBox.Type.Warning); } else if (Validation.IsValidSecurityCode(txtncode.Text)) { Utilities.notifyThem(ntfC, "Security code must contain\na-z, A-Z, 0-9 characters", NotificationBox.Type.Warning); } else { Utilities.runInThread(() => { String HashSecur = Utilities.MD5Hash(txtncode.Text.Trim()); DB TempDB = Utilities.AsyncDB(); TempDB.bind(new string[] { "Code", HashSecur }); TempDB.nQuery("UPDATE users SET securitycode=@Code WHERE id=" + Globals.logUser.id); Globals.logUser.scode = HashSecur; Utilities.clearText(txtspassword, txtncode); }).Start(); Utilities.notifyThem(ntfC, "Security Code Changed", NotificationBox.Type.Success); } }
private void btnRegister_Click(object sender, EventArgs e) { Utilities.runInThread(() => { if (Globals.Connected) { if (String.IsNullOrEmpty(txtRUser.Text.Trim()) || String.IsNullOrEmpty(txtRPass.Text) || String.IsNullOrEmpty(txtRrepeatPass.Text) || String.IsNullOrEmpty(txtREmail.Text.Trim()) || String.IsNullOrEmpty(txtRSecurityCode.Text.Trim())) { Utilities.notifyThem(ntfBox2, "All fields are necessary.", NotificationBox.Type.Warning); } else if (txtRPass.Text != txtRrepeatPass.Text) { Utilities.notifyThem(ntfBox2, "Passwords don't match.", NotificationBox.Type.Warning); } else if (!Validation.IsValidEmail(txtREmail.Text)) { Utilities.notifyThem(ntfBox2, "Email is not valid.", NotificationBox.Type.Warning); } else if (Validation.EmailAvailibility(txtREmail.Text)) { Utilities.notifyThem(ntfBox2, "Email is already exists.", NotificationBox.Type.Warning); } else if (txtRSecurityCode.Text.Length < 4) { Utilities.notifyThem(ntfBox2, "Security code must be at least 4 characters.", NotificationBox.Type.Warning); } else if (Validation.IsValidSecurityCode(txtRSecurityCode.Text)) { Utilities.notifyThem(ntfBox2, "Security code must contain\na-z, A-Z, 0-9 characters", NotificationBox.Type.Warning); } else if (Validation.UsernameAvailibility(txtRUser.Text)) { Utilities.notifyThem(ntfBox2, "Username is not available.", NotificationBox.Type.Warning); } else { String HashPass = Utilities.MD5Hash(txtRPass.Text); String HashSecur = Utilities.MD5Hash(txtRSecurityCode.Text); DB tDB = Utilities.AsyncDB(); tDB.bind(new string[] { "usern", txtRUser.Text, "pass1", HashPass, "email1", txtREmail.Text, "securcode", HashSecur }); int qreg = tDB.nQuery("INSERT INTO users (user, pass, email,securitycode) VALUES (@usern, @pass1, @email1, @securcode)"); if (qreg > 0) { Utilities.notifyThem(ntfBox2, "Successfull Registration.", NotificationBox.Type.Success); } } } else { Utilities.notifyThem(ntfBox2, "Not connected to DB!", NotificationBox.Type.Warning); } }).Start(); }