Working towards validating the username and password

This commit is contained in:
2017-08-01 14:30:07 -05:00
parent 8f4270a1ce
commit 0911479d22
3 changed files with 73 additions and 0 deletions

View File

@ -310,6 +310,8 @@ namespace EduNetworkBuilder
public static int UntaggedVLAN = -1; //If the packet is not tagged.
public static int MaxPacketsBeforeOptimizing = 50;
public static string AllowedPasswordCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!~@#$%^&*()_+{}[]/?<>,.";
public static string AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._";
/// <summary>
/// Find the global random number generator.
/// </summary>
@ -896,6 +898,22 @@ namespace EduNetworkBuilder
}
return result;
}
public static bool ValidateString(string tovalidate, string AllowedCharacters)
{
if (tovalidate == null || tovalidate == "") return false;
if (AllowedCharacters == null || AllowedCharacters == "") return false;
foreach (char one in tovalidate)
if (!AllowedCharacters.Contains(one)) return false;
return true;
}
public static bool ValidatePassword(string password)
{
return ValidateString(password, AllowedPasswordCharacters);
}
public static bool ValidateUsername(string password)
{
return ValidateString(password, AllowedUsernameCharacters);
}
}
}