本文整理汇总了C#中User.ToUserIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C# User.ToUserIdentifier方法的具体用法?C# User.ToUserIdentifier怎么用?C# User.ToUserIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.ToUserIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WelcomeToTheApplicationAsync
public async Task WelcomeToTheApplicationAsync(User user)
{
await _notificationPublisher.PublishAsync(
AppNotificationNames.WelcomeToTheApplication,
new MessageNotificationData(L("WelcomeToTheApplicationNotificationMessage")),
severity: NotificationSeverity.Success,
userIds: new[] { user.ToUserIdentifier() }
);
}
示例2: Link
public virtual async Task Link(User firstUser, User secondUser)
{
var firstUserAccount = await GetUserAccountAsync(firstUser.ToUserIdentifier());
var secondUserAccount = await GetUserAccountAsync(secondUser.ToUserIdentifier());
var userLinkId = firstUserAccount.UserLinkId ?? firstUserAccount.Id;
firstUserAccount.UserLinkId = userLinkId;
var userAccountsToLink = secondUserAccount.UserLinkId.HasValue
? _userAccountRepository.GetAllList(ua => ua.UserLinkId == secondUserAccount.UserLinkId.Value)
: new List<UserAccount> { secondUserAccount };
userAccountsToLink.ForEach(u =>
{
u.UserLinkId = userLinkId;
});
await CurrentUnitOfWork.SaveChangesAsync();
}
示例3: Register
//.........这里部分代码省略.........
};
ExternalLoginInfo externalLoginInfo = null;
if (model.IsExternalLogin)
{
externalLoginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (externalLoginInfo == null)
{
throw new ApplicationException("Can not external login!");
}
user.Logins = new List<UserLogin>
{
new UserLogin
{
LoginProvider = externalLoginInfo.Login.LoginProvider,
ProviderKey = externalLoginInfo.Login.ProviderKey
}
};
model.UserName = model.EmailAddress;
model.Password = Authorization.Users.User.CreateRandomPassword();
if (string.Equals(externalLoginInfo.Email, model.EmailAddress, StringComparison.InvariantCultureIgnoreCase))
{
user.IsEmailConfirmed = true;
}
}
else
{
if (model.UserName.IsNullOrEmpty() || model.Password.IsNullOrEmpty())
{
throw new UserFriendlyException(L("FormIsNotValidMessage"));
}
}
user.UserName = model.UserName;
user.Password = new PasswordHasher().HashPassword(model.Password);
user.Roles = new List<UserRole>();
foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
{
user.Roles.Add(new UserRole { RoleId = defaultRole.Id });
}
CheckErrors(await _userManager.CreateAsync(user));
await _unitOfWorkManager.Current.SaveChangesAsync();
if (!user.IsEmailConfirmed)
{
user.SetNewEmailConfirmationCode();
await _userEmailer.SendEmailActivationLinkAsync(user);
}
//Notifications
await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());
await _appNotifier.WelcomeToTheApplicationAsync(user);
await _appNotifier.NewUserRegisteredAsync(user);
//Directly login if possible
if (user.IsActive && (user.IsEmailConfirmed || !isEmailConfirmationRequiredForLogin))
{
AbpUserManager<Tenant, Role, User>.AbpLoginResult loginResult;
if (externalLoginInfo != null)
{
loginResult = await _userManager.LoginAsync(externalLoginInfo.Login, tenant.TenancyName);
}
else
{
loginResult = await GetLoginResultAsync(user.UserName, model.Password, tenant.TenancyName);
}
if (loginResult.Result == AbpLoginResultType.Success)
{
await SignInAsync(loginResult.User, loginResult.Identity);
return Redirect(Url.Action("Index", "Application"));
}
Logger.Warn("New registered user could not be login. This should not be normally. login result: " + loginResult.Result);
}
return View("RegisterResult", new RegisterResultViewModel
{
TenancyName = tenant.TenancyName,
NameAndSurname = user.Name + " " + user.Surname,
UserName = user.UserName,
EmailAddress = user.EmailAddress,
IsActive = user.IsActive,
IsEmailConfirmationRequired = isEmailConfirmationRequiredForLogin
});
}
catch (UserFriendlyException ex)
{
ViewBag.IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled;
ViewBag.UseCaptcha = !model.IsExternalLogin && UseCaptchaOnRegistration();
ViewBag.ErrorMessage = ex.Message;
return View("Register", model);
}
}