Beispiel #1
0
        private async void SendVerificationEmail(DeliveryMan newDeliveryMan, string userId, string code)
        {
            var ip          = UsefulMethods.GetLocalIPAddress();
            var callBackUrl = "http://" + ip + ":51044/api/ConfirmDeliveryManEmail?userId=" + userId + "&code=" + code;

            string parent = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
            string path;

            path = Path.Combine(parent, "DeliveryApp\\wwwroot\\Templates\\EmailTemplates\\ConfirmRegistration.html");


            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(path))
            {
                builder.HtmlBody = SourceReader.ReadToEnd();
            }

            string messageBody = string.Format(
                builder.HtmlBody,
                newDeliveryMan.FirstName + " " + newDeliveryMan.LastName,
                callBackUrl
                );

            await emailSenderService.SendUserConfirmationEmail(
                newDeliveryMan.Email,
                newDeliveryMan.FirstName + " " + newDeliveryMan.LastName,
                messageBody
                );
        }
Beispiel #2
0
        public async Task <Object> ForgotPassword(EmailForForgotPasswordDto emailDto)
        {
            var ip   = UsefulMethods.GetLocalIPAddress();
            var user = await _userManager.FindByEmailAsync(emailDto.Email);

            if (user != null)
            {
                var token = await _userManager.GeneratePasswordResetTokenAsync(user);

                var callBackUrl = "http://" + ip + ":51044/api/resetPassword?userId=" + user.Id + "&token=" + token;

                string parent = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
                string path;

                path = Path.Combine(parent, "DeliveryApp\\wwwroot\\Templates\\EmailTemplates\\ResetPasswordEmail.html");


                var builder = new BodyBuilder();
                using (StreamReader SourceReader = System.IO.File.OpenText(path))
                {
                    builder.HtmlBody = SourceReader.ReadToEnd();
                }

                string messageBody = string.Format(
                    builder.HtmlBody,
                    callBackUrl
                    );

                await emailSenderService.SendResetPasswordEmail(emailDto.Email, messageBody);
            }
            return(Ok(new { message = "Email envoyé." }));
        }