private KickEditorViewModel(Authentication authentication, IDomainUser domainUser) { this.authentication = authentication; this.authentication.Expired += Authentication_Expired; this.domainUser = domainUser; this.CommentHeader = Resources.Label_KickReason; this.DisplayName = Resources.Title_KickEditor; }
public EmailMessage GetMessage(IDomainUser user, AccountResult created, UserCommand command, IEnumerable <Claim> claims) { return(new EmailMessage( user.Email, Bcc, GetFormatedContent(Subject, user, created, command, claims), GetFormatedContent(Content, user, created, command, claims), Sender)); }
public DomainUserDescriptor(Authentication authentication, IDomainUser domainUser, DescriptorTypes descriptorTypes, object owner) : base(authentication, domainUser, descriptorTypes) { this.domainUser = domainUser; this.owner = owner ?? this; this.domainUser.Dispatcher.VerifyAccess(); this.domainUserInfo = domainUser.DomainUserInfo; this.domainUserState = domainUser.DomainUserState; if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true) { this.domainUser.DomainUserInfoChanged += DomainUser_DomainUserInfoChanged; this.domainUser.DomainUserStateChanged += DomainUser_DomainUserStateChanged; } }
public DomainUserDescriptor(Authentication authentication, IDomainUserDescriptor descriptor, DescriptorTypes descriptorTypes, object owner) : base(authentication, descriptor.Target, descriptorTypes) { this.domainUser = descriptor.Target; this.owner = owner ?? this; this.domainUser.Dispatcher.VerifyAccess(); this.domainUserInfo = domainUser.DomainUserInfo; this.domainUserState = domainUser.DomainUserState; if (this.descriptorTypes.HasFlag(DescriptorTypes.IsSubscriptable) == true && descriptor is INotifyPropertyChanged obj) { obj.PropertyChanged += Descriptor_PropertyChanged; this.disposeAction = new Action(() => obj.PropertyChanged -= Descriptor_PropertyChanged); } }
public bool TryFindUser(string accountName, out IDomainUser result) { result = null; var findByIdentity = UserPrincipal.FindByIdentity(this.principalContext, IdentityType.SamAccountName, accountName) ?? UserPrincipal.FindByIdentity(this.principalContext, IdentityType.UserPrincipalName, accountName); if (findByIdentity == null) { return(false); } result = new PrincipalDomainUser(findByIdentity); return(true); }
public static Color GetColor(this IDomainUser domainUser) { if (idToColor.ContainsKey(domainUser.ID) == false) { if (emptyColors.Count == 0) { emptyColors.AddRange(colors); emptyColors.Remove(AppearanceManager.Current.AccentColor); } int index = random.Next() % emptyColors.Count; idToColor.Add(domainUser.ID, emptyColors[index]); emptyColors.RemoveAt(index); } return(idToColor[domainUser.ID]); }
private async Task SendEmailToUser(IDomainUser user, UserCommand request, AccountResult accountResult, EmailType type) { if (user.EmailConfirmed) { return; } var email = await _emailRepository.GetByType(type); if (email is null) { return; } var claims = await _userService.GetClaimByName(user.UserName); await _emailService.SendEmailAsync(email.GetMessage(user, accountResult, request, claims)); }
private string GetFormatedContent(string content, IDomainUser user, AccountResult created, UserCommand command, IEnumerable <Claim> claims) { if (content is null) { return(string.Empty); } return(content .Replace("{{picture}}", claims.ValueOf(JwtClaimTypes.Picture)) .Replace("{{name}}", claims.ValueOf(JwtClaimTypes.Name, JwtClaimTypes.PreferredUserName, JwtClaimTypes.GivenName)) .Replace("{{username}}", user.UserName) .Replace("{{code}}", created.Code) .Replace("{{url}}", created.Url) .Replace("{{provider}}", command.Provider) .Replace("{{phoneNumber}}", user.PhoneNumber) .Replace("{{email}}", user.Email)); }
public DomainUserListBoxItemViewModel(Authentication authentication, IDomainUser domainUser, object owner) : base(authentication, new DomainUserDescriptor(authentication, domainUser, DescriptorTypes.All, owner), owner) { }
public static string SetDomainOwner(Authentication authentication, IDomain domain, IDomainUser domainUser) { return(string.Format(EventResources.SetDomainOwner, authentication.ID, authentication.Name, domainUser, domainUser.DomainUserInfo.UserName, domain)); }
public Task <string> CreateUserWithProviderAndPass(IDomainUser user, string password, string provider, string providerId) { return(CreateUser(user, password, provider, providerId)); }
public DomainUserListItemBase(Authentication authentication, IDomainUser domainUser, bool IsSubscriptable, object owner) : base(authentication, new DomainUserDescriptor(authentication, domainUser, IsSubscriptable == true ? DescriptorTypes.All : DescriptorTypes.IsRecursive, owner), owner) { }
public DomainUserRemovedEventArgs(Authentication authentication, IDomain domain, IDomainUser domainUser, RemoveInfo removeInfo) : base(authentication, domain, domainUser) { this.removeInfo = removeInfo; }
public Task <string> CreateUserWithPass(IDomainUser user, string password) { return(CreateUser(user, password, null, null)); }
public UserNotContainerException(IDomainUser user, Type containerType) : base($"User '{user.GetType().Name}' is not container '{containerType.Name}'") { User = user; }
public Task <string> CreateUserWithProvider(IDomainUser user, string provider, string providerUserId) { return(CreateUser(user, null, provider, providerUserId)); }
public UsersController(IDomainUser domain, ILogger <UsersController> logger) { this.domain = domain; this.logger = logger; }
private async Task <string> CreateUser(IDomainUser user, string password, string provider, string providerId) { var newUser = new UserIdentity { PhoneNumber = user.PhoneNumber, Email = user.Email, UserName = user.UserName, Name = user.Name, Picture = user.Picture }; IdentityResult result; if (provider.IsPresent()) { var userByProvider = await _userManager.FindByLoginAsync(provider, providerId); if (userByProvider != null) { await _bus.RaiseEvent(new DomainNotification("New User", $"User already taken with {provider}")); } } if (password.IsMissing()) { result = await _userManager.CreateAsync(newUser); } else { result = await _userManager.CreateAsync(newUser, password); } if (result.Succeeded) { // User claim for write customers data //await _userManager.AddClaimAsync(newUser, new Claim("User", "Write")); var code = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); var callbackUrl = $"{_config.GetValue<string>("ApplicationSettings:UserManagementURL")}/confirm-email?user={user.Email.UrlEncode()}&code={code.UrlEncode()}"; await _emailSender.SendEmailConfirmationAsync(user.Email, callbackUrl); await AddClaims(newUser); if (!string.IsNullOrWhiteSpace(provider)) { await AddLoginAsync(newUser, provider, providerId); } if (password.IsPresent()) { _logger.LogInformation("User created a new account with password."); } if (provider.IsPresent()) { _logger.LogInformation($"Provider {provider} associated."); } return(newUser.Id); } foreach (var error in result.Errors) { await _bus.RaiseEvent(new DomainNotification(result.ToString(), error.Description)); } return(null); }
public DomainUserEventArgs(Authentication authentication, IDomain domain, IDomainUser domainUser) : base(authentication, domain) { this.domainUserInfo = domainUser.DomainUserInfo; this.domainUserState = domainUser.DomainUserState; }