Example #1
0
 // GET: Home
 public ActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         LoginViewModel viewModel = new LoginViewModel();
         viewModel.allDiv = _tutorials.tutorialUser(User.Identity.Name).allDiv;
         viewModel.cookies = _tutorials.tutorialUser(User.Identity.Name).cookies;
         viewModel.homeDiv = _tutorials.tutorialUser(User.Identity.Name).homeDiv;
         return View(viewModel);
     }
     else
     {
         return View();
     }
 }
Example #2
0
        public ActionResult Login(LoginViewModel modelLogin, string returnUrl)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }
            UserDto user = new UserDto();

            user.Login = modelLogin.Login;
            user.Password = modelLogin.Password;

            if (_userService.LoginUser(user) == 1)
            {
                FormsAuthentication.SetAuthCookie(modelLogin.Login, true);

                return RedirectToAction("Index", "Home");
            }
            else if (_userService.LoginUser(user) == 2 || _userService.LoginUser(user) == 3)
            {
                errors.Add("Login bądź hasło niepoprawne.");
            }
            else if (_userService.LoginUser(user) == 4)
            {
                return View("~/Views/Error/_Blocked.cshtml");
            }

            Session["val"] = errors.ToArray<string>();

            return View(modelLogin);
        }