Example #1
0
        public bool VerifyUser(string token, out string userName)
        {
            string decryptedToken = EncryptionManager.DecryptRijndael(token, "J962006#n4302009");

            if (decryptedToken == null)
            {
                userName = null;
                return(false);
            }

            string[] split = decryptedToken.Split('|');

            string potentialMatch = split[0];

            User user = _repo.Query(u => u.EmailAddress == potentialMatch).FirstOrDefault();

            if (user != null)
            {
                if (DateTime.Parse(split[1]) >= DateTime.Now.Date)
                {
                    userName         = user.UserName;
                    user.IsValidated = true;
                    _repo.Save();
                    return(true);
                }
            }
            userName = null;
            return(false);
        }
        public ActionResult Login(string returnUrl)
        {
            HttpCookie cookie = Request.Cookies.Get("TntqTrackit");

            if (cookie != null)
            {
                string value = EncryptionManager.DecryptRijndael(cookie.Value);
                connection.Open();
                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = "Select * from users where username='******',')[1] + "' AND (active = 1 OR active is null)";
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    //int a = dr.GetInt32(8);

                    FormsAuthentication.SetAuthCookie(value, true);
                    Session["ShowVouchers"] = dr.GetBoolean(13);
                    if (string.IsNullOrEmpty(returnUrl))
                    {
                        return(RedirectToAction("AddBookingB", "Booking"));
                    }
                    return(RedirectToLocal(returnUrl));
                }
            }

            ViewBag.ReturnUrl = returnUrl;
            return(View());
        }