Working towards validating the username and password
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user