コード例 #1
0
        public async Task <IHttpActionResult> SendConfirmation()
        {
            var userId = User.Identity.GetUserId();

            Logger.InfoWithIp(CurrentClassName, nameof(SendConfirmation), $"Send confirmation to email request for user id '{userId}'");
            var isEmailAlreadyConfirmed = await repository.IsEmailConfirmed(userId);

            if (isEmailAlreadyConfirmed)
            {
                return(Ok("Email is already confirmed"));
            }

            var email = await repository.GetEmailByUserId(userId);

            var token = await repository.GetEmailConfirmationToken(userId);

            Logger.Debug(CurrentClassName, nameof(SendConfirmation), $"Generating url confirmation link...");
            var callbackUrl = Url.Link("GetConfirmationRoute", new { userId, token });

            var emailProvider = new EmailProvider(Logger);

            await emailProvider.SendAsync(email, "Email Confirmation", $"For email confirmation go to the link: {callbackUrl}");

            return(Ok("Confirmation email was sended"));
        }
コード例 #2
0
        public async Task SendEmailAsync(string toAddress, string body)
        {
            var imagePaths = new Dictionary <string, string>();

            if (HttpContext.Current != null)
            {
                imagePaths.Add("myImageID", HttpContext.Current.Server.MapPath("~/Content/Images/LogManLogo.jpg"));
            }

            await EmailProvider.SendAsync("", toAddress, "Logman Alert!", body, imagePaths);
        }
コード例 #3
0
ファイル: AccountBusiness.cs プロジェクト: nsaud01/Logman
        public void SendCreateUserConfirmationEmail(User user, string activationUrl)
        {
            string templateBody =
                "Dear @Name,<br>Your LogMan account is pending confirmation.Please clcick here to activate your account: <a href='@Link'>Activate</a><br>";
            var imagePaths = new Dictionary <string, string>();

            if (HttpContext.Current != null)
            {
                string emailTemplate = HttpContext.Current.Server.MapPath("~/App_Data/Templates/ConfirmEmail.html");
                templateBody = File.ReadAllText(emailTemplate)
                               .Replace("@Name", user.Username)
                               .Replace("@Link", activationUrl)
                               .Replace("@Password", user.Password);
                imagePaths.Add("myImageID", HttpContext.Current.Server.MapPath("~/Content/Images/LogManLogo.jpg"));
            }

            EmailProvider.SendAsync("", user.Username, "Confirm Your LogMan Account!", templateBody, imagePaths);
        }