Exemplo n.º 1
0
        public static bool forgotpasse(forgotpass newfor)
        {
            bool status = false;

            try
            {
                using (MySqlConnection con = new MySqlConnection(connString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }

                    string query = "INSERT INTO forgotpass (email,token,created_on) VALUES(@email,@token,default)";

                    MySqlCommand cmd = new MySqlCommand(query, con);
                    cmd.Parameters.Add(new MySqlParameter("@email", newfor.email));
                    cmd.Parameters.Add(new MySqlParameter("@token", newfor.token));



                    cmd.ExecuteNonQuery();
                    con.Close();
                    status = true;
                }
            }
            catch (MySqlException e)
            {
                string message = e.Message;
            }

            return(status);
        }
        public ActionResult Forgot(string uemail)
        {
            Customer newcust = new Customer
            {
                email = uemail
            };

            bool status = BussinessManager.validateforgot(uemail);

            if (status)
            {
                int    number = 10;
                string str    = GenerateRandomAlphanumericString(number);



                string GenerateRandomAlphanumericString(int length)
                {
                    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

                    var random       = new Random();
                    var randomString = new string(Enumerable.Repeat(chars, length)
                                                  .Select(s => s[random.Next(s.Length)]).ToArray());

                    return(randomString);
                }

                forgotpass newfor = new forgotpass
                {
                    email = uemail,
                    token = str
                };
                string url = "http://*****:*****@bookter.in", uemail, "Regarding password reset", "<!DOCTYPE html><html><head><title>Password Reset</title><link rel='stylesheet' href='css/font-awesome.css'><link rel='stylesheet' href='css/style.css'><link href='https://fonts.googleapis.com/css2?family=Miriam+Libre:wght@400;700&display=swap' rel='stylesheet'></head><body><div class='container' style='width: 100%;height: 100vh;min-height: 100vh;'><h1 class='p-y-medium' style='font-family: Nunito;;padding-top: 0.75rem;padding-bottom: 0.75rem;'>Hello User</h1><p class='p-y-medium' style='font-family: Nunito;;padding-top: 0.75rem;padding-bottom: 0.75rem;'>You just requested for your password reset.</p><p class='p-y-medium' style='font-family: Nunito;;padding-top: 0.75rem;padding-bottom: 0.75rem;'><a href='" + url + "'>Here's</a> the link if the button did not word.</p><p class='m-y-wide' style='font-family: Nunito;;margin-top: 1rem;margin-bottom: 1rem;'><strong>Thank you!</strong></p></div></body></html>");

                bool status1 = BussinessManager.forgotpasse(newfor);
                //return this.RedirectToRoute("index", "home");
                if (status1)
                {
                    return(this.RedirectToRoute(""));
                }
            }

            return(View());
        }
 public static bool forgotpasse(forgotpass newfor)
 {
     return(LoginDBManager.forgotpasse(newfor));
 }