Esempio n. 1
0
        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
            var user = new ApplicationUser() { UserName = model.Email};
            var result = await UserManager.CheckPasswordAsync(user, model.Password);
            switch (result)
            {
                case true:
                    List<Claim> claims = new List<Claim>();
                    claims.Add(new Claim(ClaimTypes.NameIdentifier, model.Email));
                    claims.Add(new Claim(ClaimTypes.Name, model.Email));
                    
                    ClaimsIdentity ci = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
                    AuthenticationManager.SignIn(new AuthenticationProperties()
                    {
                        AllowRefresh = true,
                        IsPersistent = false

                    }, ci);
                    Session["UserCredentials"] = new UserSessionInfo(model.Email,model.Password,model.Company);
                    sxAPIHelper filentApiHelper = new sxAPIHelper(model.Email,model.Password,model.Company);
                    filentApiHelper.Login();
                    Session["filenet"] = filentApiHelper;
                    return RedirectToLocal(returnUrl);
                case false:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }
 public FolderDirectoryController()
 {
     filenetApiHelper = (sxAPIHelper) System.Web.HttpContext.Current.Session["filenet"];
     filenetApiHelper.Login();
     objectStore = filenetApiHelper.GetObjectStore();
 }