Ejemplo n.º 1
0
        //RESET PASSWORD
        public Guide ResetPassword(object email)
        {
            Guide g = new Guide();

            g = g.GetGuideByEmail(email.ToString());
            var          fromAddress  = new MailAddress("*****@*****.**", "IsraAdvisor App");
            var          toAddress    = new MailAddress(email.ToString(), g.FirstName);
            const string fromPassword = "******";
            const string subject      = "Reset Password";
            string       randPass     = RandomPassword();
            string       temp         = "Hello " + g.FirstName + " " + g.LastName + " your New Password is: " + randPass;
            string       body         = temp;

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
            DBservices db = new DBservices();

            db.ChangePass(randPass, g.gCode);

            g.PasswordGuide = randPass;
            g.Email         = email.ToString();
            return(g);
        }