Ejemplo n.º 1
0
        public static void SendPasswordEmail(MembershipUser user, string password, PasswordEmailType passwordEmailType)
        {
            assertExists(user);
            assertHasEmail(user);

            string body = passwordEmailTemplate.Replace("<%LoginName%>", user.UserName)
                                               .Replace("<%Password%>", password);

            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-firstTime",
                                                                   passwordEmailType == PasswordEmailType.FirstTime);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-reset",
                                                                   passwordEmailType == PasswordEmailType.Reset);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-changedByUser",
                                                                   passwordEmailType == PasswordEmailType.ChangedByUser);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-not-changedByUser",
                                                                   passwordEmailType != PasswordEmailType.ChangedByUser);

            MailMessage message = new MailMessage();

            string testRecipients = ConfigurationManager.AppSettings.Get("TestEmailRecipients");
            message.To.Add(testRecipients == null ? user.Email : testRecipients);

            message.Subject = "Your new Total Giro password";
            message.Body = body;
            message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }
Ejemplo n.º 2
0
        internal void SetPassword(IDalSession session, LoginPerson loginPerson, PasswordEmailType passwordEmailType)
        {
            loginPerson.AssertHasEmail();

            string password = SecurityManager.GeneratePassword(passwordLength);
            SecurityManager.SetPassword(loginPerson.Login.UserName, password);

            setPasswordSent(session, loginPerson.Login, true);

            try
            {
                SendPasswordEmail(loginPerson, password, passwordEmailType);
            }
            catch (Exception ex)
            {
                setPasswordSent(session, loginPerson.Login, false);
                throw new ApplicationException("Error sending e-mail after password was (re)set.", ex);
            }
        }
Ejemplo n.º 3
0
 public static void SendPasswordEmail(string userName, string password, PasswordEmailType passwordEmailType)
 {
     SendPasswordEmail(Membership.GetUser(userName), password, passwordEmailType);
 }
Ejemplo n.º 4
0
        internal void SendPasswordEmail(LoginPerson loginPerson, string password, PasswordEmailType passwordEmailType)
        {
            string clientWebsiteUrl = (loginPerson.AssetManager.StichtingDetails.ClientWebsiteUrl ?? "").TrimEnd('/');
            if (string.IsNullOrEmpty(clientWebsiteUrl))
                throw new ApplicationException("Client Website URL not known.");

            string body = passwordEmailTemplate.Replace("<%DearSirForm%>", loginPerson.DearSirForm)
                                               .Replace("<%LoginNameEnding%>",
                                                        loginPerson.Login.UserName.Substring(loginPerson.Login.UserName.Length - 3))
                                               .Replace("<%Password%>", password)
                                               .Replace("<%ClientWebsiteUrl%>", clientWebsiteUrl);

            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-firstTime",
                                                                   passwordEmailType == PasswordEmailType.FirstTime);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-reset",
                                                                   passwordEmailType == PasswordEmailType.Reset);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-changedByUser",
                                                                   passwordEmailType == PasswordEmailType.ChangedByUser);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "passwordEmailType-not-changedByUser",
                                                                   passwordEmailType != PasswordEmailType.ChangedByUser);

            body = ApplicationLayer.Utility.ShowOptionalTag(body, "loginType-customer",
                                                                   loginPerson.Login.LoginType == LoginTypes.Customer);
            body = ApplicationLayer.Utility.ShowOptionalTag(body, "loginType-remisierEmployee",
                                                                   loginPerson.Login.LoginType == LoginTypes.RemisierEmployee);

            MailMessage message = new MailMessage();

            loginPerson.AssertHasEmail();
            string testRecipients = ConfigurationManager.AppSettings.Get("TestEmailRecipients");
            message.To.Add(testRecipients == null ? loginPerson.Email : testRecipients);

            message.Subject = "Paerel portefeuille";
            message.Body = body;
            message.IsBodyHtml = true;

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }