protected void ResetPassword_OnClick(object sender, EventArgs e)
        {
            string newPassword = "";

                try
                {

                    u = Membership.GetUser(MemberUserName.Text, false);
                    newPassword = u.ResetPassword(AnswerTextBox.Text);

                    if (newPassword != null)
                    {
                        Msg.Text = "Password reset. Your new password is: " + Server.HtmlEncode(newPassword);
                    }
                    else
                    {
                        Msg.Text = "Password reset failed. Please re-enter your values and try again.";
                    }
                }
                catch (MembershipPasswordException ex)
                {
                    Msg.Text = "Invalid password answer. Please re-enter and try again.";
                    return;
                }
                catch (Exception ee)
                {
                    Msg.Text = ee.Message;
                    return;
                }
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            //string pw = Membership.GeneratePassword(8, 1);
            // u = Membership.GetUser();

               string MembershipUserName = Membership.GetUserNameByEmail(Email.Text.Trim());
               string strmsg = "";

               if (MembershipUserName == UserName.Text.Trim())
               {

               u = Membership.GetUser(UserName.Text.Trim(), false);
               try
               {
                   string newPassword = "";
                   newPassword = u.ResetPassword();

                   string strMailTo = Email.Text.Trim();
                   string strMsgTitle = "Rent-House Password Recovery Details";
                   string strMsgContent = message(Server.HtmlEncode(newPassword), "user's name");

                  int rtn = SendEmail(u.Email, strMsgTitle, strMsgContent);

                  if (rtn == 1)
                   {
                         strmsg = "New password request accepted! Please check your email.";
                   }
                   else
                   {
                         strmsg = "New password request not accepted! Please try again.";
                   }
               }
               catch (MembershipPasswordException ex1)
               {
                   strmsg = "New password request not accepted! Please try again.";
                   return;
               }
               catch (Exception ex2)
               {
                   strmsg = "New password request not accepted! Please try again.";
                   return;
               }
               }
               else
               {
               strmsg = "Enter correct User details!";
               return;
               }
        }
        /// <summary>
        /// Changes password and removes hash from DDS
        /// </summary>
        /// <param name="user"></param>
        /// <param name="newPassword"></param>
        /// <param name="hash"></param>
        /// <returns></returns>
        public bool ChangePassword(MembershipUser user, string newPassword, string hash)
        {
            bool success = false;
            //change password
            if (user != null)
            {
                // reset password to retrieve current password
                string resetPw = user.ResetPassword();
                success = user.ChangePassword(resetPw, newPassword);
                // clean up - remove reset link from dds
                if (!string.IsNullOrEmpty(hash))
                    _resetPasswordRespository.Delete(hash);
            }

            return success;
        }
Beispiel #4
0
        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            Guid userId = JocysCom.ClassLibrary.Security.Helper.GetUserId <Guid>(ResetKeyLabel.Text);
            var  user   = Data.User.GetUser(userId);

            System.Web.Security.MembershipUser muser = Membership.GetUser(user.UserName);
            // Reset password: Start
            string tempPassword = muser.ResetPassword();

            muser.ChangePassword(tempPassword, NewPassword.Text);
            Membership.UpdateUser(muser);
            // Reset password: End
            SuccessPanel.Visible        = true;
            ChangePasswordPanel.Visible = false;
            RedirectionPanel.Visible    = true;
        }
Beispiel #5
0
        protected void ResetPassword_OnClick(object sender, EventArgs e)
        {
            string newPassword;

            System.Web.Security.MembershipUser u = Membership.GetUser(txtRecover.Text, false);

            if (u == null)
            {
                Msg.Text = "Usuario " + Server.HtmlEncode(txtRecover.Text) + " No encontrado.";
                return;
            }

            try
            {
                newPassword = u.ResetPassword();
            }
            catch (MembershipPasswordException)
            {
                Msg.Text = "Respuesta Invalida.";
                return;
            }
            catch (Exception)
            {
                //Msg.Text = e.Message;
                return;
            }

            if (newPassword != null)
            {
                MailController mail = new MailController();
                mail.SendMailRecovery("Solicitud Cambio de Clave ServiTarjeta", txtRecover.Text, Server.HtmlEncode(newPassword));
                Msg.Text      = "Correcto: Enviada la nueva contraseña a su correo electronico.";
                Msg.ForeColor = System.Drawing.Color.Red;


                // Msg.Text = "Contraseña reseteada. Su nueva Clave es: " + Server.HtmlEncode(newPassword);
            }
            else
            {
                Msg.Text = "Recuperacion de Contraseña fallido.";
            }
        }
 public string ResetPassword(MembershipUser user)
 {
     return user.ResetPassword();
 }
Beispiel #7
0
        public ActionResult ForgotPassword(string email)
        {
            UserAccount ua = new UserAccount();
            ua.GetUserAccountByEmail(email);

            if (ua.UserAccountID == 0)
            {
                ViewBag.Result = Messages.NotFound;
            }
            else
            {
                ua.FailedPasswordAnswerAttemptCount = 0;
                ua.FailedPasswordAttemptCount = 0;
                ua.IsLockedOut = false;
                ua.Update();

                mu = Membership.GetUser(ua.UserName);
                string newPassword = mu.ResetPassword();

                BootBaronLib.Operational.Utilities.SendMail(email, BootBaronLib.Configs.AmazonCloudConfigs.SendFromEmail, Messages.PasswordReset,
                   Messages.UserName + ": " + ua.UserName + Environment.NewLine +
                    Environment.NewLine + Messages.NewPassword + ": " + newPassword +
                    Environment.NewLine +
                Environment.NewLine + Messages.SignIn + ": " + BootBaronLib.Configs.GeneralConfigs.SiteDomain);

                ViewBag.Result = Messages.CheckYourEmailAndSpamFolder;
            }

            return View();
        }
        private string GetRestorePasswordMessage( MembershipUser user )
        {
            string password;
              string templateFileName;

              try
              {
            try
            {
              password = user.GetPassword();
              templateFileName = "restorePassword.txt";
            }
            catch ( Exception exc )
            {
              log.WarnFormat(
            "First chance exception when tried to get the password for {0} ({1}): {2}",
            user.UserName,
            user.Email,
            exc.Message
              );
              password = user.ResetPassword();
              templateFileName = "resetPassword.txt";
            }
              }
              catch ( Exception exc )
              {
            log.FatalFormat(
              "Can't {0} user password for {1} ({2}): {3}",
              Membership.EnablePasswordRetrieval ? "get" : "reset",
              user.UserName,
              user.Email,
              exc.Message
            );
            throw;
              }

              string templatePath = Path.Combine( HttpRuntime.AppDomainAppPath, "EmailTemplates" );
              templatePath = Path.Combine( templatePath, templateFileName );
              string messageText =
            File.ReadAllText( templatePath )
            .Replace( "<%UserName%>", user.UserName )
            .Replace( "<%Password%>", password )
            .Replace( "<%AdminEmail%>", Settings.Default.AdminEmail );

              return messageText;
        }
Beispiel #9
0
        public ActionResult ForgotPassword(string email)
        {
            var ua = new UserAccount();
            ua.GetUserAccountByEmail(email);

            if (ua.UserAccountID == 0)
            {
                ViewBag.Result = Messages.NotFound;
            }
            else
            {
                ua.FailedPasswordAnswerAttemptCount = 0;
                ua.FailedPasswordAttemptCount = 0;
                ua.Update();

                _mu = Membership.GetUser(ua.UserName);

                if (_mu != null)
                {
                    string newPassword = _mu.ResetPassword();

                    _mail.SendMail(AmazonCloudConfigs.SendFromEmail, email, Messages.PasswordReset,
                        string.Format("{0}: {1}{2}{2}{3}: {4}{2}{2}{5}: {6}",
                            Messages.UserName, ua.UserName, Environment.NewLine,
                            Messages.NewPassword, newPassword, Messages.SignIn, GeneralConfigs.SiteDomain));
                }

                ViewBag.Result = Messages.CheckYourEmailAndSpamFolder;
            }

            return View();
        }
 public void ResetPassword(MembershipUser membershipUser)
 {
     var newPassword = membershipUser.ResetPassword();
     var body = string.Format(@"This is a password reset notification from LogWhatever.com. Your password has been reset to <b>{0}</b>. You will need to use this new password when you next log on.", newPassword);
     MailSender.Send(ConfigurationProvider.FromEmailAddress, membershipUser.UserName, "LogWhatever Password Reset", body);
 }
Beispiel #11
0
 /// <summary>
 /// Change user password
 /// </summary>
 /// <param name="user">Membership user</param>
 /// <param name="newPassword">new password</param>
 /// <returns>Return true if password changed</returns>
 public bool ChangePassword(MembershipUser user, string newPassword)
 {
     return user.ChangePassword(user.ResetPassword(), newPassword);
 }
Beispiel #12
0
        //Return the passwordResetRequest object for the given user
        //Sends an email to the user with a link to the PasswordResetRequest's page
        public static PasswordResetRequest GenerateFor(MembershipUser user)
        {
            PasswordResetRequest resetReq = null;
            using (DREAMContext db = new DREAMContext())
            {
                resetReq = new PasswordResetRequest();
                {
                    resetReq.ID = PasswordResetRequest.GenerateNewID();
                    resetReq.UserID = (Guid)user.ProviderUserKey;
                }
                db.SaveChanges();

                String newPassword = user.ResetPassword();

                SendEmail("*****@*****.**", user.Email, "", "", "DREAM Password Reset", newPassword);

                return resetReq;
            }
        }
 public string ResetPassword(MembershipUser user, string passwordAnswer)
 {
     return user.ResetPassword(passwordAnswer);
 }
Beispiel #14
0
 public bool ChangePassword(string password)
 {
     return(membershipUser.ChangePassword(membershipUser.ResetPassword(), password));
 }
Beispiel #15
0
        public static bool ChangeUserPassword(MembershipUser user, string newPassword, string verificationId)
        {
            try
            {
                string newPass = string.Empty;
                try
                {
                    newPass = user.ResetPassword();
                }
                catch (Exception exception)
                {
                    if (exception.Message.Contains("user account has been locked out"))
                    {
                        user.UnlockUser();
                        newPass = user.ResetPassword();
                    }
                    else
                        ErrorDatabaseManager.AddException(exception, exception.GetType());
                }
                bool changed = user.ChangePassword(newPass, newPassword);
                var tempUser = GetMember(user.UserName);

                SendEmailForPasswordChanged(user.Email, tempUser.DerbyName);
                var dc = new ManagementContext();
                var verify = dc.EmailVerifications.Where(x => x.VerificationId == new Guid(verificationId)).FirstOrDefault();
                if (verify != null)
                {
                    dc.EmailVerifications.Remove(verify);
                    int c = dc.SaveChanges();
                }
                return changed;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());

            }
            return false;
        }
        public void SendResetEmail(MembershipUser user)
        {
            //The URL to login
            if (HttpContext.Request.Url == null) return;
            var domain = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) +
                            HttpRuntime.AppDomainAppVirtualPath;

            //link to send
            var link = domain + "/Account/Logon";

            var body = "<p> Dear " + user.UserName + ",</p>";
            body += "<p> Your Orion password has been reset, Click " + link + " to login with details below</p>";
            body += "<p> UserName: "******"</p>";
            body += "<p> Password: "******"</p>";
            body += "<p>It is recomended that you change it after logon.</p>";
            body += "<p>If you did not request a password reset you do not need to take any action.</p>";

            var plainView = AlternateView.CreateAlternateViewFromString
                (System.Text.RegularExpressions.Regex.Replace(body, @"<(.|\n)*?>", string.Empty), null, "text/plain");

            var htmlView = AlternateView.CreateAlternateViewFromString(body, null, "text/html");

            var message = new MailMessage("haithem-araissia.com", user.Email)
                {
                    Subject = "Password Reset",
                    BodyEncoding = System.Text.Encoding.GetEncoding("utf-8"),
                    IsBodyHtml = true,
                    Priority = MailPriority.High,
                };

            message.AlternateViews.Add(plainView);
            message.AlternateViews.Add(htmlView);

            var smtpMail = new SmtpClient();
            var basicAuthenticationInfo = new System.Net.NetworkCredential("*****@*****.**",
                                                                           "haithem759163");
            smtpMail.Host = "mail.haithem-araissia.com";
            smtpMail.UseDefaultCredentials = false;
            smtpMail.Credentials = basicAuthenticationInfo;
            try
            {
                smtpMail.Send(message);
            }
            catch (Exception)
            {
                RedirectToAction("Index", "Home");
                throw;
            }
        }
            public void SendResetEmail(MembershipUser user)
            {
            //The URL to login
            string domain = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority) + HttpRuntime.AppDomainAppVirtualPath;

            //link to send
            string link = domain + "/Home/PassReset?userName={0}&oldPassword={1}";
            link = link.Replace("//", "/");

            string newPassword = user.ResetPassword();
            link = string.Format(link, user.UserName, newPassword);

            var body = @"<html>
            <head>
            <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">
            <title>ForexBox</title>
            <style type=""text/css"">
            body, #header h1, #header h2, p {margin: 0; padding: 0;}
            </style>
            </head>
            <body>
            <table width=""100%""  cellpadding=""0"" cellspacing=""0"" style=""font-size:12px;line-height:22px;font-family:Arial,sans-serif;color:#555555;table-layout:fixed"">
            <tbody><tr><td style=""background-color:#ededed;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <table rules=""none"" frame=""border"" width=""400"" align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""font-size:12px;border-collapse:collapse;border:0px solid #e4e2e4;line-height:22px;font-family:Arial,sans-serif;color:#555555;border-spacing:0;border:solid 1px #ededed;cursor:default;"">
            <tbody><tr><td valign=""top"" style=""background-color:#ededed;border-collapse:collapse;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""margin-top:24px;color:#555555;font-family:Arial,sans-serif;font-size:12px;line-height:22px"">
            <tbody><tr>
            <td valign=""top"" width=""150"" style=""font-size:25px; text-shadow: 1px 1px white;font-weight:bold;font-family:Tahoma,sans-serif;color:#333;padding-bottom:10px""><a style=""color:#666;font-size:24px"">Forex</a><a style=""color:#F84040;font-size:24px"">Box</a></td>
            <td valign=""top"" align=""right"" style=""text-align:right;font-size:12px;line-height:16px;font-family:Arial,sans-serif;color:#3fb6dd;padding-top:6px"">
            <a style=""color:#666;font-size:14px; text-shadow: 1px 1px white"" href=""http://4rexbox.com"" target=""_blank"">Главная</a>&nbsp;&nbsp;&nbsp;
            <a style=""color:#666;font-size:14px; text-shadow: 1px 1px white"" href=""http://4rexbox.com/Home/News"" target=""_blank"">Новости</a>&nbsp;&nbsp;&nbsp;
            </td>
            </tr>
            </tbody></table>
            </td></tr>
            <tr><td valign=""top"" bgcolor=""#ffffff"" style=""border-top:solid 1px #e0e0e0;background-color:#ffffff;border-collapse:collapse;color:#555555;font-family:Arial,sans-serif;font-size:10px;line-height:18px"">
            <table width=""400"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""40"">&nbsp;</td></tr></tbody></table>
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"">
            <tbody><tr><td valign=""top"" style=""color:#666;font-family:Arial,sans-serif;font-size:14px;line-height:20px"">
            <span style=""font-size:17px;line-height:10px;font-weight:bold;color:#666;text-align:center"">
            Здравствуйте уважаемый(мая)

            "
                + user.UserName +

            @"
            </span>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            Вы отправили заявку для смены пароля<br> от Вашего кабинета ForexBox.
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            Пройдите по следующей <a href=" + link + @">ссылке</a> <br>
            Или скопируйте ее в адрессную строку:<br><br>
            <i>" + link + @"</i><br><br>
            И в появившейся странице введите Ваш новый пароль.<br>

            </td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""20""></td></tr></tbody></table>
            </td></tr>
            <tr><td valign=""top"" bgcolor=""#d9ecff"" style=""background-color:#fafafa;border-top:solid 1px #e0e0e0;border-bottom:solid 1px #e0e0e0;color:#777777;font-family:Arial,sans-serif;font-size:14px;line-height:19px"">
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""20""></td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center""><tbody><tr><td style=""color:#666;font-family:Arial,sans-serif;font-size:14px;font-weight:normal;line-height:19px"">
            Если Вы не отправляли заявку для смены пароля,<br>
            то просто проигнорируйте это письмо.<br><br>
            Если у Вас есть какие-либо вопросы, пожалуйста,<br>
            обращайтесь к нам в тех-поддержку.<br><br>
            Еще раз благодарим за сотрудничество, и желаем<br>
            успешной торговли вместе с ForexBox!<br>
            </td></tr></tbody></table>
            <table width=""400"" cellpadding=""0"" cellspacing=""0"" align=""center"" style=""clear:both""><tbody><tr><td height=""32""></td></tr></tbody></table>
            </td></tr>
            <tr><td valign=""top"" style=""background-color:#ededed;border-collapse:collapse;color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px;border-top:solid 1px #e0e0e0"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px""><tbody><tr>
            <td valign=""top"" style=""font-size:10px;border-top-color:#eeeeee;line-height:18px;font-family:Arial,sans-serif;color:#777777;border-top-style:solid;border-top-width:1px"">
            <table width=""400"" align=""center"" cellpadding=""0"" cellspacing=""0"" style=""color:#777777;font-family:Arial,sans-serif;font-size:10px;line-height:18px"">
            <tbody><tr>
            <td valign=""top"" width=""160"" style=""color:#999999;font-family:Arial,sans-serif;font-size:11px;line-height:16px"">
            <b style=""font-weight:bold;color:#333"">«ForexBox»</b>
            <br><a href=""http://4rexbox.com"" style=""color:#3279bb;text-decoration:underline"" target=""_blank"">www.4rexbox.com</a>
            <br><a style=""color:#3279bb;text-decoration:underline"">[email protected]</a>
            </td>
            </tr>
            </tbody></table>
            <table width=""450"" cellpadding=""0"" cellspacing=""0""><tbody><tr><td height=""40""></td></tr></tbody></table>
            </td>
            </tr></tbody></table>
            </td></tr>
            </tbody></table>
            </td></tr></tbody></table>
            </body>
            ";

            AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString
            (System.Text.RegularExpressions.Regex.Replace(body, @"<(.|\n)*?>", string.Empty), null, "text/plain");

            AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(body, null, "text/html");
            SendMail(user.Email, "Password reset", body);

            /*
            var message = new MailMessage("*****@*****.**", user.Email)
            {
                Subject = "Password Reset",
                BodyEncoding = System.Text.Encoding.GetEncoding("utf-8"),
                IsBodyHtml = true,
                Priority = MailPriority.High,
            };

            message.AlternateViews.Add(plainView);
            message.AlternateViews.Add(htmlView);
            var client = new SmtpClient("smtp.gmail.com");
            client.Port = 587;

            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "pefe2o3go");
            client.EnableSsl = true;

            client.Send(message);*/
        }
 public void ChangePassword(MembershipUser user, string newPassword)
 {
     var resetPassword = user.ResetPassword();
     if (!user.ChangePassword(resetPassword, newPassword))
         throw new MembershipPasswordException("Could not change password.");
 }
 public void ChangePassword(MembershipUser membershipUser, string newPassword)
 {
     string tempPassword = membershipUser.ResetPassword();
     membershipUser.ChangePassword(tempPassword, newPassword);
 }