public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
                return RedirectToAction("Index", "Home");

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(Membership.GetUserNameByEmail(model.Email), model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult FogotPassword(LogOnModel model)
        {
            if (User.Identity.IsAuthenticated)
                return RedirectToAction("Index", "Home");

            try
            {
                MembershipUser currentUser = Membership.GetUser(Membership.GetUserNameByEmail(model.Email));
                var password = currentUser.ResetPassword();

                var emailModel = new
                {
                    UserName = currentUser.UserName,
                    Url = password
                };
                MailMessage mail = PitchingTubeEntities.Current.GenerateEmail("recoverpassword", emailModel);
                mail.To.Add(model.Email);

                Mailer.SendMail(mail);
                return RedirectToAction("FogotPasswordSuccess");
            }
            catch
            {
                ViewBag.Message = "Your account has not been activated. You can register now";
                return View();
            }
        }