Updated username regex to not allow uppercase characters

This commit is contained in:
Junior 2023-06-09 19:47:07 -03:00
parent d319a7d4d7
commit 086b25b83b
6 changed files with 4781 additions and 4703 deletions

View file

@ -471,7 +471,7 @@
// NamePictureBox
//
NamePictureBox.BackColor = Color.Transparent;
NamePictureBox.Location = new Point(383, 151);
NamePictureBox.Location = new Point(379, 151);
NamePictureBox.Name = "NamePictureBox";
NamePictureBox.Size = new Size(14, 14);
NamePictureBox.TabIndex = 39;
@ -494,7 +494,7 @@
NameDescLabel.Font = new Font("Segoe UI", 8F, FontStyle.Bold, GraphicsUnit.Point);
NameDescLabel.ForeColor = Color.White;
NameDescLabel.ImeMode = ImeMode.NoControl;
NameDescLabel.Location = new Point(399, 152);
NameDescLabel.Location = new Point(395, 152);
NameDescLabel.MaximumSize = new Size(250, 0);
NameDescLabel.Name = "NameDescLabel";
NameDescLabel.Size = new Size(158, 13);

View file

@ -15,9 +15,6 @@ namespace RHLauncher
private readonly System.Windows.Forms.Timer resendTimer = new();
private int secondsLeft = 60;
[GeneratedRegex("^(?=.*[a-zA-Z])[a-zA-Z0-9]+$")]
private static partial Regex MyRegex();
public RegForm()
{
InitializeComponent();
@ -271,7 +268,9 @@ namespace RHLauncher
private bool NameTextBoxValid = false;
private void NameTextBox_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(NameTextBox.Text) || NameTextBox.Text.Length < 6 || NameTextBox.Text.Length > 16 || !MyRegex().IsMatch(NameTextBox.Text))
Regex nameregex = new("^(?=.*[a-z])[a-z0-9]+$");
if (string.IsNullOrEmpty(NameTextBox.Text) || NameTextBox.Text.Length < 6 || NameTextBox.Text.Length > 16 || !nameregex.IsMatch(NameTextBox.Text) || HasUppercase(NameTextBox.Text))
{
if (string.IsNullOrEmpty(NameTextBox.Text))
{
@ -287,7 +286,14 @@ namespace RHLauncher
NamePictureBox.Image = imageListTips.Images[0];
NameTextBoxValid = false;
}
else if (!MyRegex().IsMatch(NameTextBox.Text))
else if (HasUppercase(NameTextBox.Text))
{
NameDescLabel.Text = LocalizedStrings.UsernameDescLabelUppercase;
NameDescLabel.ForeColor = Color.Red;
NamePictureBox.Image = imageListTips.Images[0];
NameTextBoxValid = false;
}
else if (!nameregex.IsMatch(NameTextBox.Text))
{
NameDescLabel.Text = LocalizedStrings.UsernameDescLabelInvalid;
NameDescLabel.ForeColor = Color.Red;
@ -304,6 +310,11 @@ namespace RHLauncher
CheckFormS2Validity();
}
private static bool HasUppercase(string text)
{
return text.Any(char.IsUpper);
}
private bool PasswordTextBoxValid = false;
private void PasswordTextBox_TextChanged(object sender, EventArgs e)
{

File diff suppressed because it is too large Load diff