Skip to content

Commit

Permalink
Add a "minimum 8 characters" password requirement
Browse files Browse the repository at this point in the history
This will now be a requirement if the user chooses to encrypt their chat history file.
  • Loading branch information
ProudlyTM committed Nov 23, 2021
1 parent 6e0b162 commit 4cc7e8b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 3 additions & 1 deletion ChatClientServer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class Form1 : Form
private StreamReader STR;
private StreamWriter STW;
private TcpClient client;

protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.WindowsShutDown || e.CloseReason == CloseReason.ApplicationExitCall)
Expand Down Expand Up @@ -154,6 +154,8 @@ private void Form1_Load(object sender, EventArgs e)

if (File.ReadLines(chatHistory).First() != "control_line_DO_NOT_DELETE")
{
child.lblPassword.Font = new Font(child.lblPassword.Font.FontFamily, 9);
child.lblPassword.Left = 55;
child.lblPassword.Text = "Enter your password";

while (maxTries <= 3)
Expand Down
10 changes: 6 additions & 4 deletions ChatClientServer/FormPassword.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions ChatClientServer/FormPassword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,30 @@ private void btnShowHidePassword_Click(object sender, EventArgs e)

private void btnOKPassword_Click(object sender, EventArgs e)
{
if (textBoxPassword.Text != "")
if (lblPassword.Text != "Enter your password")
{
IsBtnOKPressed = true;
Close();
if (textBoxPassword.Text != "" && textBoxPassword.Text.Length >= 8)
{
IsBtnOKPressed = true;
Close();
}
else
{
MessageBox.Show("You need to enter a new password!\n\nThe password should be at least 8 characters long.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("You need to enter a password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (textBoxPassword.Text != "" && textBoxPassword.Text.Length >= 8)
{
IsBtnOKPressed = true;
Close();
}
else
{
MessageBox.Show("Your password should be at least 8 characters long!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

Expand Down

0 comments on commit 4cc7e8b

Please sign in to comment.