summaryrefslogtreecommitdiff
path: root/Aktywator/MainForm.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-10-11 17:27:18 +0200
committeremkael <emkael@tlen.pl>2018-10-11 19:26:10 +0200
commitecd99235cc16c52fb6364e67848a1a761c655ef2 (patch)
tree2a22d2eee53732dd3196fe573af9f4792657d018 /Aktywator/MainForm.cs
parentcbf1e8ff15377e0bf4b9ddee0a868e4ab85a6cc0 (diff)
PIN safety improvements:
* initializing BWS settings with randomized PIN * checking PIN against predictable PINs (with explicit warning on settings save) * generating randomized PIN easily
Diffstat (limited to 'Aktywator/MainForm.cs')
-rw-r--r--Aktywator/MainForm.cs37
1 files changed, 37 insertions, 0 deletions
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();
+ }
}
}