public virtual ActionResult SignIn(AuthVm.SignIn model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var authMgr = HttpContext.GetOwinContext().Authentication;
            var authSvc = new ActiveDirectoryAuthenticationManager(authMgr);
            var authRes = authSvc.SignIn(model.Username, model.Password);

            if (authRes.IsSuccess)
            {
                return(RedirectToAction("Index", "App"));
            }
            GetAlert(Danger, authRes.ErrorMessage);
            ModelState.AddModelError("", authRes.ErrorMessage);
            return(View(model));
        }
Beispiel #2
0
        public virtual ActionResult SignIn(AuthVm.SignIn model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // usually this will be injected via DI. but creating this manually now for brevity
            var authenticationManager = HttpContext.GetOwinContext().Authentication;
            var authService           = new AdAuthenticationService(authenticationManager);

            var authenticationResult = authService.SignIn(model.Username, model.Password);

            if (authenticationResult.IsSuccess)
            {
                // we are in!
                return(RedirectToAction("Index", "App"));
                //return RedirectToLocal(returnUrl);
            }
            GetAlert(Danger, authenticationResult.ErrorMessage);
            ModelState.AddModelError("", authenticationResult.ErrorMessage);
            return(View(model));
        }