Пример #1
0
        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));
            }
        }
Пример #2
0
        public ActionResult ResetPassword(string token, string txtPassword1, string txtPassword2)
        {
            var model = new bat.logic.ViewModels.Homepage.ResetPassword();

            try
            {
                model = _passwdService.VerifyToken(token);
                var account = _passwdService.ChangePassword(token, txtPassword1, txtPassword2);

                var auth = new logic.Rules.Authentication(Request.GetOwinContext());
                auth.Login(account);

                return(RedirectToRoute("home"));
            }
            catch (Exception ex)
            {
                ViewBag.ErrMsg = ex.Message;
            }
            return(View(model));
        }
Пример #3
0
        public ActionResult Swap(int id)
        {
            var model = new logic.Rules.Swap();

            try
            {
                var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser();
                if (user == null)
                {
                    return(RedirectToRoute("home"));
                }

                model.Load(user, id);
                var auth = new logic.Rules.Authentication(Request.GetOwinContext());
                auth.Login(model.account);
            }
            catch (Exception ex)
            {
                ViewBag.LoginErrMsg = ex.Message;
            }

            return(RedirectToRoute("home"));
        }
Пример #4
0
        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"));
            }
        }
Пример #5
0
        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"));
            }
        }