public ActionResult Index(
            string type, string firstname, string lastname, string email, string password)
        {
            var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser();

            if (user != null)
            {
                return(RedirectToRoute("home"));
            }

            var model = new bat.logic.ViewModels.Homepage.Landing();

            try
            {
                ViewBag.firstName = firstname;
                ViewBag.lastName  = lastname;
                ViewBag.email     = email;
                model             = _homeService.Signup(Convert.ToInt32(type), firstname, lastname, email, password);

                var auth = new logic.Rules.Authentication(Request.GetOwinContext());
                auth.Login(auth.GetUser(email, password));
                return(RedirectToRoute("home"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View("Landing", model));
            }
        }
        public ActionResult Register(string type, string firstname, string lastname, string email, string password, string returnUrl)
        {
            try
            {
                ViewBag.firstName = firstname;
                ViewBag.lastName  = lastname;
                ViewBag.email     = email;
                var rs = _homeService.Signup(Convert.ToInt32(type), firstname, lastname, email, password);

                var auth = new logic.Rules.Authentication(Request.GetOwinContext());
                auth.Login(auth.GetUser(email, password));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View("LoginSignup"));
            }

            //returnURL needs to be decoded
            string decodedUrl = "";

            if (!string.IsNullOrEmpty(returnUrl))
            {
                decodedUrl = Server.UrlDecode(returnUrl);
            }

            //Login logic...

            if (Url.IsLocalUrl(decodedUrl))
            {
                return(Redirect(decodedUrl));
            }
            else
            {
                return(RedirectToRoute("home"));
            }
        }
        public ActionResult login(string txtUsername, string txtPassword, string returnUrl)
        {
            // not already logged in, so continue
            Session.Clear();
            System.Threading.Thread.Sleep(250); // slight delay to deter bots

            try
            {
                var auth = new logic.Rules.Authentication(Request.GetOwinContext());
                auth.Login(auth.GetUser(txtUsername, txtPassword));
            }
            catch (Exception ex)
            {
                ViewBag.LoginErrMsg = ex.Message;
                return(View());
            }

            //returnURL needs to be decoded
            string decodedUrl = "";

            if (!string.IsNullOrEmpty(returnUrl))
            {
                decodedUrl = Server.UrlDecode(returnUrl);
            }

            //Login logic...

            if (Url.IsLocalUrl(decodedUrl))
            {
                return(Redirect(decodedUrl));
            }
            else
            {
                return(RedirectToRoute("home"));
            }
        }