Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByEmailAsync(Input.Email);

                // For more information on how to enable account confirmation and password reset please
                // visit https://go.microsoft.com/fwlink/?LinkID=532713
                var code = await _userManager.GeneratePasswordResetTokenAsync(user);

                var callbackUrl = Url.Page(
                    "/Account/ResetPassword",
                    pageHandler: null,
                    values: new { code },
                    protocol: Request.Scheme);

                NotificationTypeDTO notification = new NotificationTypeDTO
                {
                    Title   = "Reset Password",
                    Message = $"Please reset your password by link: {HtmlEncoder.Default.Encode(callbackUrl)}"
                };

                _notificationService.SendMail(Input.Email, notification);

                return(RedirectToPage("./ForgotPasswordConfirmation"));
            }

            return(Page());
        }
Ejemplo n.º 2
0
        private NotificationTypeDTO CreateNotification(TaskDTO task, string role)
        {
            NotificationTypeDTO notification = new NotificationTypeDTO
            {
                Title   = task.Title,
                Message =
                    $"You are {role} on a new task" + "\n" +
                    $"Title: {task.Title}" + "\n" +
                    $"Description: {task.Description}" + "\n" +
                    "\n" +
                    $"Start Date: {task.CreationTime}" + "\n" +
                    $"Deadline: {task.EndDate}" + "\n" +
                    "\n" +
                    $"Best wishes," + "\n" +
                    $"Task Manager System",
            };

            return(notification);
        }
Ejemplo n.º 3
0
        public void SendMail(string email, NotificationTypeDTO notification)
        {
            using (var message = new MailMessage("*****@*****.**", email))
            {
                message.To.Add(new MailAddress(email));
                message.From = new MailAddress("*****@*****.**");

                message.Subject = notification.Title;
                message.Body    = notification.Message;

                using (var smtpClient = new SmtpClient("smtp.gmail.com"))
                {
                    smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Kakoka911");
                    smtpClient.EnableSsl   = true;
                    smtpClient.Port        = 2525;
                    smtpClient.Send(message);
                }
            }
        }