From ecd99235cc16c52fb6364e67848a1a761c655ef2 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 11 Oct 2018 17:27:18 +0200 Subject: PIN safety improvements: * initializing BWS settings with randomized PIN * checking PIN against predictable PINs (with explicit warning on settings save) * generating randomized PIN easily --- Aktywator/MainForm.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'Aktywator/MainForm.cs') diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs index 6284419..3a5b69b 100644 --- a/Aktywator/MainForm.cs +++ b/Aktywator/MainForm.cs @@ -678,5 +678,42 @@ namespace Aktywator } } + + internal void checkPINsafety(string pin, int[] unsafePINs, bool explicitWarning = false) + { + try + { + if (Array.IndexOf(unsafePINs, Int32.Parse(pin)) > -1) + { + this.lPINWarning.Visible = true; + if (explicitWarning) + { + MessageBox.Show("Próbujesz ustawić PIN, który jest łatwy do przewidzenia przez zawodników.\n\nMam nadzieję, że wiesz, co robisz!", "Przewidywalny PIN!", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + else + { + this.lPINWarning.Visible = false; + } + } + catch (FormatException e) + { + } + } + + private void xPINcode_TextChanged(object sender, EventArgs e) + { + this.checkPINsafety(this.xPINcode.Text, this.bws._unsafePINs); + } + + private void lPINWarning_Click(object sender, EventArgs e) + { + this.checkPINsafety(this.xPINcode.Text, this.bws._unsafePINs, true); + } + + private void bRandomPIN_Click(object sender, EventArgs e) + { + this.xPINcode.Text = this.bws._getRandomPIN(); + } } } -- cgit v1.2.3