public async Task SendPasswordResetEmailAync(string email) { var user = await _userManager.FindByEmailAsync(email); if (user != null && user.IsEmailConfirmed) // Don't reveal that the user does not exist or is not confirmed { //password reset token var passwordResetToken = await _userManager.GeneratePasswordResetTokenAsync(user); string encodedPasswordResetToken = WebUtility.UrlEncode(passwordResetToken); var systemHostUrlGetTask = _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.SystemHostUrl); var setPasswordActionGetTask = _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.SetPasswordAction); var systemHostUrl = await systemHostUrlGetTask; var setPasswordControllerAction = await setPasswordActionGetTask; var passwordResetUrl = $"{systemHostUrl}/{setPasswordControllerAction}/{user.Id}/{user.Email}/{encodedPasswordResetToken}/{true}"; await _alertNotificationRequestService.NotifyAsync( SystemKeys.AlertTemplateKeys.ResetPassword, SystemKeys.AlertChannelKeys.Email, new Dictionary <string, object> { { AlertObjectContextTypes.User, user.Id } }, new Dictionary <string, string> { { "passwordResetUrl", passwordResetUrl } }, user.Id); } }
private async Task CreateDefaultGroupRoleForLoggedInUser(string groupId) { var defaultGroupRole = await _configurationReaderService.GetValueAsync(ConfigurationKeys.DefaultGroupRole); await _userService.AddGroupRoleToUserAsync(_requestContext.UserId, new UserGroupRole { Group = groupId, Role = defaultGroupRole }); }
public async Task ExportAndNotifyAsync(string masterReportType, string reportType, IEnumerable <string> columnLocalisationKeys, IEnumerable <IEnumerable <object> > contentList) { var user = await _systemDataContext.GetDocumentAsync <User>(_requestContext.UserId); var expirySetting = await _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.ReportExportExpiryHours); var expiryHours = int.Parse(expirySetting); var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(user.TimeZone); var userDateTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, userTimeZone); var reportName = await _lookupReaderService.GetTextAsync("LIST_" + masterReportType, reportType); var blobInfo = await ExportAndGenerateBlobAsync(reportName, columnLocalisationKeys, contentList, expiryHours, userDateTime); var reportAlertInfo = new ReportAlertInfo { ExpiryHours = expiryHours, GeneratedOnUtc = DateTime.UtcNow, ReportName = reportName, DownloadUrl = blobInfo.BlobUri + blobInfo.SasToken, }; await _alertNotificationRequestService.NotifyAsync( SystemKeys.AlertTemplateKeys.ReportExport, SystemKeys.AlertChannelKeys.Email, new Dictionary <string, object> { { AlertObjectContextTypes.Report, reportAlertInfo }, { AlertObjectContextTypes.User, user.Id } }, null, user.Id); }
public async Task <IBlobService> CreateBlobServiceAsync(string container, string basePath) { var connectionString = await _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.StoragePrimaryConnectionString); var blobService = new AzureBlobStorageService(connectionString, container, basePath); return(blobService); }
private async Task <int> GetPINLengthForGivenGroup(string group) { int.TryParse(await _configurationReaderService.GetValueAsync(ConfigurationValueType.pinLength, group), out int pinLengthFromConfig); if (pinLengthFromConfig == 0) { pinLengthFromConfig = 4; } return(pinLengthFromConfig); }
public async Task SendAsync(string content, string subject, string senderId, User recipientUser) { var from = new EmailAddress(senderId); var to = new EmailAddress(recipientUser.Email); var msg = MailHelper.CreateSingleEmail(from, to, subject, null, content); var apiKey = await _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.SendGridApiKey); var _sendGridClient = new SendGridClient(apiKey); await _sendGridClient.SendEmailAsync(msg); }
public async Task <Dictionary <string, string> > GetContextObjectKeyValuesAsync(object objectInfo, string groupId, string culture, string timeZone) { var productName = await _localisationReaderService.GetTextAsync(SystemKeys.LocalisationKeys.ProductName, groupId, culture); var companyName = await _localisationReaderService.GetTextAsync(SystemKeys.LocalisationKeys.CompanyName, groupId, culture); var logoUrl = await _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.SystemLogoUrl, groupId, culture); var dic = new Dictionary <string, string> { { "productName", productName }, { "companyName", companyName }, { "logoUrl", logoUrl } }; return(dic); }
private async Task <QueueClient> CreateQueueClientAsync(string queueName) { var serviecBusConnectionString = await _configurationService.GetValueAsync(SystemKeys.ConfigurationKeys.ServiceBusConnectionString); return(new QueueClient(serviecBusConnectionString, queueName)); }