Exemplo n.º 1
0
        public ActionResult CompletedLogin(CompleteLoginModel model)
        {
            if (!_memeberShipService.IsUserRegistered(model.UserName.Trim()))
            {
                // If we got this far, something failed, redisplay form
                ModelState.AddModelError("", "User has not been registered.");
                return(View("FinishLogin", model));
            }

            try
            {
                if (!_memeberShipService.AuthenticateUser(model.UserName.Trim(), model.DeviceResponse.Trim()))
                {
                    throw new Exception("Device response did not work with user.");
                }

                FormsAuthentication.SetAuthCookie(model.UserName, true);
                return(RedirectToAction("Index", "Profile"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                ModelState.AddModelError("", "Error authenticating");
                return(View("FinishLogin", model));
            }
        }
Exemplo n.º 2
0
        public ActionResult CompletedLogin(CompleteLoginModel model)
        {
            if (!_memeberShipService.IsUserRegistered(model.UserName.Trim()))
            {
                // If we got this far, something failed, redisplay form
                ModelState.AddModelError("", "User has not been registered");
                return(View("FinishLogin", model));
            }

            try
            {
                if (_memeberShipService.AuthenticateUser(model.UserName.Trim(), model.DeviceResponse.Trim()))
                {
                    return(View("CompletedLogin", model));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                ModelState.AddModelError("", "Error finding challenge");
                return(View("FinishLogin", model));
            }

            return(View("FinishLogin", model));
        }