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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -19,8 +19,8 @@
<AssemblyName>Launcher</AssemblyName> <AssemblyName>Launcher</AssemblyName>
<Description>Rusty Hearts Launcher</Description> <Description>Rusty Hearts Launcher</Description>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<AssemblyVersion>1.0.1</AssemblyVersion> <AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.1</FileVersion> <FileVersion>1.0.2</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -31,10 +31,6 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="RHLauncher.LauncherForm\LauncherForm.resx~RF3c0dbfb.TMP" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\rhicon.ico" /> <Content Include="Resources\rhicon.ico" />
</ItemGroup> </ItemGroup>

View file

@ -735,6 +735,15 @@ namespace RHLauncher.RHLauncher {
} }
} }
/// <summary>
/// Looks up a localized string similar to Username must not contain uppercase letters. Please use only lowercase letters and digits..
/// </summary>
public static string UsernameDescLabelUppercase {
get {
return ResourceManager.GetString("UsernameDescLabelUppercase", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Username/Email. /// Looks up a localized string similar to Username/Email.
/// </summary> /// </summary>

View file

@ -342,6 +342,9 @@
<data name="UsernameDescLabelSize" xml:space="preserve"> <data name="UsernameDescLabelSize" xml:space="preserve">
<value>Username must be between 6-16 characters</value> <value>Username must be between 6-16 characters</value>
</data> </data>
<data name="UsernameDescLabelUppercase" xml:space="preserve">
<value>Username must not contain uppercase letters. Please use only lowercase letters and digits.</value>
</data>
<data name="UsernameLabel" xml:space="preserve"> <data name="UsernameLabel" xml:space="preserve">
<value>Username/Email</value> <value>Username/Email</value>
</data> </data>