Ejemplo n.º 1
0
        public async Task <IActionResult> ResetPassword(Guid key)
        {
            ApplicationUser foundUser = await userManager.FindByIdAsync(key);

            if (foundUser == null)
            {
                return(BadRequest("User was not found."));
            }

            ApplicationUser currentUser = await userManager.GetUserAsync(User);

            if (foundUser.GlobalAdmin && !currentUser.GlobalAdmin)
            {
                return(Forbid());
            }

            string newPassword = Guid.NewGuid().ToString().Replace("-", "");

            IdentityResult result = await userManager.ResetPasswordAsync(foundUser, await userManager.GeneratePasswordResetTokenAsync(foundUser), newPassword);

            if (!result.Succeeded)
            {
                return(BadRequest("Reset password failed."));
            }

            await emailNotificator.SendEmailAsync(foundUser.Email, "Reset password",
                                                  $"Your password was reset.\n\nUserName: {foundUser.UserName}\nNew password: {newPassword}");

            return(Ok($"New password was send to email. ({foundUser.Email})"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Odesle postupne vsechny notifikace co jsou ve fronte.
        /// </summary>
        /// <returns></returns>
        public async Task SendAllNotifications()
        {
            NotifyItem notifyItem = await queue.PopAsync <NotifyItem>(QueueType.Notification);

            while (notifyItem != null)
            {
                switch (notifyItem.ChannelType)
                {
                case ChannelType.Email:
                    await emailNotificator.SendEmailAsync(notifyItem.Contact, notifyItem.Subject, notifyItem.Message);

                    break;

                default:
                    logger.LogError($"Notificaiton sending for '{notifyItem.ChannelType}' not implemented yet.");
                    break;
                }

                notifyItem = await queue.PopAsync <NotifyItem>(QueueType.Notification);
            }
        }
Ejemplo n.º 3
0
        public async Task ProcessQueueMessage([TimerTrigger("%MonitoringInterval%" /*, RunOnStartup = true*/)] TimerInfo timerInfo, TextWriter log)
        {
            try
            {
                var msg = "Start monitor: " + DateTime.Now;

                logger.LogInformation(msg);

                //monitoring.CheckMonitors(serviceProvider);

                await notificator.SendAllNotifications();
            }
            catch (Exception ex)
            {
                string email = NotificationEmailOnError;
                if (email != null)
                {
                    await emailNotificator.SendEmailAsync(email, "!!! MONITORING WEBJOB DOWN !!!", "Console application to monitoring websites is down."
                                                          + $"{Environment.NewLine}Exception:{Environment.NewLine}" + ex.ToString());
                }
            }
        }