public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            //if (!ModelState.IsValid)
            //{
            //    return View(model);
            //}

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            AuthorizationPresenter presenter = new AuthorizationPresenter();
            var token = presenter.Authenticate(model.UserName, model.Password, "1");

            if (token != null)
            {
                TokenContainer.SetToken(token);
            }

            //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (token.HasLogin)
            {
            case true:
                return(RedirectToLocal(returnUrl));

            case false:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public ActionResult LoginToken()
        {
            AuthorizationPresenter presenter = new AuthorizationPresenter();
            var token = presenter.Authenticate("username", "password", "1");

            if (token != null)
            {
                TokenContainer.SetToken(token);
            }

            //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (token.HasLogin)
            {
            case true:
                return(RedirectToAction("About", "Home"));

            case false:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(RedirectToAction("Index", "Home"));
            }
        }