本文整理汇总了C#中Domain.SetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# Domain.SetPassword方法的具体用法?C# Domain.SetPassword怎么用?C# Domain.SetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain.SetPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateAndCreate
private INotification ValidateAndCreate(Domain.User user)
{
var notification = _validator.Validate(user);
if (notification.IsValid())
{
//verify valid password
if (!_passwordValidator.ValidatePassword(user.Password))
{
notification.RegisterMessage("Password", _settings.Password.GetValidationMessage(), Severity.Error);
return notification;
}
//make sure user is unique
if(_userRepository.FindBy(x => x.UserName, user.UserName) != null)
{
notification.RegisterMessage("UserName", "User name already exists!", Severity.Error);
return notification;
}
//make sure email is unique
if (_userRepository.FindBy(x => x.Email, user.Email) != null)
{
notification.RegisterMessage("Email", "Email already exists!", Severity.Error);
return notification;
}
switch (_settings.Password.PasswordFormat)
{
case PasswordFormat.Hashed:
user.SetPassword(_passwordHelperService);
break;
case PasswordFormat.Clear:
user.SetPassword(new ClearPasswordHelper());
break;
case PasswordFormat.Encrypted:
throw new NotImplementedException();
break;
default:
throw new ArgumentOutOfRangeException();
}
_userRepository.Save(user);
}
return notification;
}