Esempio n. 1
0
        public async Task <bool> ForgotPassword(ForgotPasswordViewModel forgotPasswordViewModel)
        {
            var forgotPasswordRequest = new ForgotPasswordRequest(forgotPasswordViewModel.EmailAddress);
            var getUserByEmailRequest = new GetUserByEmailRequest {
                EmailAddress = forgotPasswordViewModel.EmailAddress
            };

            var clientInfo   = UserAgentParser.Extract(_userAgent);
            var userResponse = await _bus.RequestAsync(getUserByEmailRequest);

            var name = Helpers.GetUserName(userResponse.User);
            var forgotPasswordResponse = await _bus.RequestAsync(forgotPasswordRequest);

            var actionurl = $"{_baseUrl}/Account/ChangePassword/{forgotPasswordResponse.Secret}";

            var emailTemplateRequest = new EmailTemplateRequest(EmailType.ForgotPassword);
            var response             = await _bus.RequestAsync(emailTemplateRequest);

            var template = TemplateContentBuilder.Build(response.Template,
                                                        TemplateContentBuilder.CreateForgotPasswordTemplateContent(name, actionurl, clientInfo.OperatingSystem, clientInfo.BrowserName));

            var email = new EmailEvent(new EmailAddress("noreply", "*****@*****.**"), new EmailAddress(name, forgotPasswordViewModel.EmailAddress), "Wachtwoord vergeten ikdoneer.nu",
                                       template, true);

            await _bus.PublishAsync(email);

            return(true);
        }
Esempio n. 2
0
        private async Task SendActivationTokenEmail(string userName, string emailAddress, string activationToken)
        {
            var actionurl            = $"{_baseUrl}/Account/ActivateAccount?Token={activationToken}";
            var emailTemplateRequest = new EmailTemplateRequest(EmailType.ConfirmAccount);
            var response             = await _bus.RequestAsync(emailTemplateRequest);

            var template = TemplateContentBuilder.Build(response.Template,
                                                        TemplateContentBuilder.CreateConfirmAccountTemplateContent(userName, actionurl));

            var email = new EmailEvent(new EmailAddress("noreply", "*****@*****.**"), new EmailAddress(userName, emailAddress), "Account activatie ikdoneer.nu",
                                       template, true);

            await _bus.PublishAsync(email);
        }