Store Emails (#3611)

* Store Emails

* fix test

* Update email rules layout

* Cleanups

* Test cleanups

* Add back comments

* Update view; add test

* Show email rules link even if email settings aren't completed

* Validate email addresses

* No redirect, display warning

* Fix test

* Refactoring: Change email argument types to MailAddress

* Test fix

* Refactoring: Use MailboxAddress

* Parse emails properly in controllers and backend

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Andrew Camilleri
2022-06-22 05:05:32 +02:00
committed by GitHub
parent af93cf2adb
commit c2d72e71aa
30 changed files with 429 additions and 120 deletions

View File

@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using MimeKit;
namespace BTCPayServer.Controllers
{
@@ -164,8 +165,8 @@ namespace BTCPayServer.Controllers
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = _linkGenerator.EmailConfirmationLink(user.Id, code, Request.Scheme, Request.Host, Request.PathBase);
var email = user.Email;
(await _EmailSenderFactory.GetEmailSender()).SendEmailConfirmation(email, callbackUrl);
var address = new MailboxAddress(user.UserName, user.Email);
(await _EmailSenderFactory.GetEmailSender()).SendEmailConfirmation(address, callbackUrl);
TempData[WellKnownTempData.SuccessMessage] = "Verification email sent. Please check your email.";
return RedirectToAction(nameof(Index));
}