public ActionResult Login(LogInViewModel model, string returnUrl)
        {
            var user = dbContext.Instance.AdminLogIn(model.Username, model.Password);

            if (user != null)
            {
                SessionManager.Instance.username = user.Username;
                SessionManager.Instance.userid = user.UserID;
                SessionManager.Instance.UserRights = UserRights.Admin;

                return RedirectToAction("UserList", "User");
            }
            else
            {
                return View(model);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Login(LogInViewModel model, string returnUrl)
        {
            var user = dbContext.Instance.ClientLogIn(model.Username, model.Password);

            if (user != null)
            {
                SessionManager.Instance.username = user.Username;
                SessionManager.Instance.userid = user.UserID;
                SessionManager.Instance.UserRights = user.IsMultiUser
                    ? UserRights.MultiUser
                    : user.IsSubUser ? UserRights.User : UserRights.MonoUser;

                return View("UserList", GetUserViewModel());
            }
            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 result =  SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
            */
        }