Esempio n. 1
0
        public async Task Generate_ConfirmEmailToken_And_ConfirmEmail()
        {
            ApplicationUser applicationUser = await _applicationUserRepository.FindByNameOrEmailAsync("admin");

            Assert.IsNotNull(applicationUser);

            string confirmationToken =
                await _applicationUserRepository.GenerateEmailConfirmationTokenAsync(applicationUser);

            Assert.IsNotNull(confirmationToken);

            ApplicationUser result =
                await _applicationUserRepository.ConfirmEmailAsync(applicationUser, confirmationToken);

            Assert.IsNotNull(result);
            Assert.IsTrue(applicationUser.EmailConfirmed);
        }
Esempio n. 2
0
        public async Task Handle(DomainEventNotification <SavedPerson> notification, CancellationToken cancellationToken)
        {
            Client client = notification.DomainEvent.Client;

            string emailConfirmationToken =
                await _applicationUserRepository.GenerateEmailConfirmationTokenAsync(client.User);

            UriBuilder uriBuilder = new UriBuilder(KaizenHttpContext.BaseUrl)
            {
                Path  = "user/ConfirmEmail",
                Query = $"token={emailConfirmationToken.Base64ForUrlEncode()}&email={client.User.Email}"
            };
            string emailConfirmationLink = uriBuilder.ToString();

            string emailMessage = _mailTemplate.LoadTemplate("NewClient.html",
                                                             $"{client.FirstName} {client.LastName}",
                                                             $"{client.TradeName}", $"{client.ClientAddress.City}",
                                                             $"{client.ClientAddress.Neighborhood}", $"{client.ClientAddress.Street}",
                                                             $"{emailConfirmationLink}");

            await _mailService.SendEmailAsync(client.User.Email, "Cliente Registrado", emailMessage, true);
        }