public async Task SendNewUserEmailParticipants(HearingDetailsResponse hearing,
                                                       Dictionary <string, User> newUsernameAdIdDict)
        {
            foreach (var item in newUsernameAdIdDict)
            {
                if (!string.IsNullOrEmpty(item.Value?.Password))
                {
                    var participant = hearing.Participants.FirstOrDefault(x => x.Username == item.Key);

                    if (participant == null)
                    {
                        continue;
                    }

                    var request = AddNotificationRequestMapper.MapToNewUserNotification(hearing.Id, participant, item.Value.Password);
                    // Send a notification only for the newly created users
                    await _notificationApiClient.CreateNewNotificationAsync(request);
                }
            }
        }
Esempio n. 2
0
        public async Task ResetParticipantPassword(string userName)
        {
            _logger.LogDebug("Attempting to reset AD user {Username}", userName);
            var userProfile = await _userApiClient.GetUserByAdUserNameAsync(userName);

            if (userProfile == null)
            {
                var e = new UserServiceException
                {
                    Reason = "Unable to generate new password"
                };
                _logger.LogError(e, "Unable to reset password for AD user {Username}", userName);
                throw e;
            }

            _logger.LogDebug("AD user {Username} found", userName);
            var passwordResetResponse = await _userApiClient.ResetUserPasswordAsync(userName);

            _logger.LogDebug("AD user {Username} password has been reset", userName);
            var passwordResetNotificationRequest = AddNotificationRequestMapper.MapToPasswordResetNotification(
                $"{userProfile.FirstName} {userProfile.LastName}", passwordResetResponse.NewPassword,
                userProfile.Email);
            await _notificationApiClient.CreateNewNotificationAsync(passwordResetNotificationRequest);
        }