本文整理汇总了C#中IUserRepository.GetByEmail方法的典型用法代码示例。如果您正苦于以下问题:C# IUserRepository.GetByEmail方法的具体用法?C# IUserRepository.GetByEmail怎么用?C# IUserRepository.GetByEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserRepository
的用法示例。
在下文中一共展示了IUserRepository.GetByEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(string email, IUserRepository repository)
{
if (!string.IsNullOrEmpty(email))
{
User = repository.GetByEmail(email);
}
}
示例2: ResolveUserByWindowsIdentity
private static User ResolveUserByWindowsIdentity(IUserRepository repository, WindowsIdentity windowsIdentity)
{
// 1. User is already registered by Windows identity
var user = repository.GetByUsername(windowsIdentity.Name);
if (user == null)
{
// 2. User is already registered, but not associated with a Windows identity
var email = UserPrincipal.Current.EmailAddress;
user = repository.GetByEmail(email);
if (user == null)
{
// 3. User is not registered, but is authenticated
user = repository.CreateFromWindowsIdentity(windowsIdentity);
}
else
{
// Associate registered user with this identity
user.Username = windowsIdentity.Name;
user.IsActivated = true;
}
repository.Save(user);
}
return user;
}