本文整理汇总了C#中DotNetNuke.Security.PortalSecurity.ValidateInput方法的典型用法代码示例。如果您正苦于以下问题:C# PortalSecurity.ValidateInput方法的具体用法?C# PortalSecurity.ValidateInput怎么用?C# PortalSecurity.ValidateInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Security.PortalSecurity
的用法示例。
在下文中一共展示了PortalSecurity.ValidateInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Validate
private bool Validate()
{
CreateStatus = UserCreateStatus.AddUser;
var portalSecurity = new PortalSecurity();
//Check User Editor
bool _IsValid = userForm.IsValid;
if (RegistrationFormType == 0)
{
//Update UserName
if (UseEmailAsUserName)
{
User.Username = User.Email;
if (String.IsNullOrEmpty(User.DisplayName))
{
User.DisplayName = User.Email.Substring(0, User.Email.IndexOf("@", StringComparison.Ordinal));
}
}
//Check Password is valid
if (!RandomPassword)
{
//Check Password is Valid
if (CreateStatus == UserCreateStatus.AddUser && !UserController.ValidatePassword(User.Membership.Password))
{
CreateStatus = UserCreateStatus.InvalidPassword;
}
if (RequirePasswordConfirm && String.IsNullOrEmpty(AuthenticationType))
{
if (User.Membership.Password != User.Membership.PasswordConfirm)
{
CreateStatus = UserCreateStatus.PasswordMismatch;
}
}
}
else
{
//Generate a random password for the user
User.Membership.Password = UserController.GeneratePassword();
User.Membership.PasswordConfirm = User.Membership.Password;
}
}
else
{
//Set Username to Email
if (String.IsNullOrEmpty(User.Username))
{
User.Username = User.Email;
}
//Set DisplayName
if (String.IsNullOrEmpty(User.DisplayName))
{
User.DisplayName = String.IsNullOrEmpty(User.FirstName + " " + User.LastName)
? User.Email.Substring(0, User.Email.IndexOf("@", StringComparison.Ordinal))
: User.FirstName + " " + User.LastName;
}
//Random Password
if (String.IsNullOrEmpty(User.Membership.Password))
{
//Generate a random password for the user
User.Membership.Password = UserController.GeneratePassword();
}
//Password Confirm
if (!String.IsNullOrEmpty(User.Membership.PasswordConfirm))
{
if (User.Membership.Password != User.Membership.PasswordConfirm)
{
CreateStatus = UserCreateStatus.PasswordMismatch;
}
}
}
//Validate Profanity
if (UseProfanityFilter)
{
if (!portalSecurity.ValidateInput(User.Username, PortalSecurity.FilterFlag.NoProfanity))
{
CreateStatus = UserCreateStatus.InvalidUserName;
}
if (!String.IsNullOrEmpty(User.DisplayName))
{
if (!portalSecurity.ValidateInput(User.DisplayName, PortalSecurity.FilterFlag.NoProfanity))
{
CreateStatus = UserCreateStatus.InvalidDisplayName;
}
}
}
//Validate Unique User Name
UserInfo user = UserController.GetUserByName(PortalId, User.Username);
if (user != null)
{
if(UseEmailAsUserName)
{
//.........这里部分代码省略.........