Ejemplo n.º 1
0
        public ActionResult SignIn(SignInInput input)
        {
            if (!ModelState.IsValid)
            {
                input.Password = null;
                input.Login = null;
                return View(input);
            }

            User user;

            //ACHTUNG: remove this in a real app
            if (input.Login == "o" && input.Password == "1")
            {
                user = new User { Login = "******", Roles = new[] { new Role { Name = "admin" } } };
            }
            else
            {
                user = userService.Get(input.Login, input.Password);
            }

            if (user == null)
            {
                ModelState.AddModelError("", "Try Login: o and Password: 1");
                return View();
            }

            SignInOwin(user.Login, input.Remember, user.Roles.Select(o => o.Name));

            return RedirectToAction("index", "home");
        }
Ejemplo n.º 2
0
        public ActionResult SignIn(SignInInput input)
        { 
            if (!ModelState.IsValid)
            {
                input.Password = null;
                input.Login = null;
                return View(input);
            }

            var user = us.Get(input.Login, input.Password);
            
            //ACHTUNG: remove this line in a real app
            if (user == null && input.Login == "o" && input.Password == "1") user = new User {Login = "******", Roles = new[]{new Role{Name = "admin"}}};

            if (user == null)
            {
                ModelState.AddModelError("", "Try Login: o and Password: 1");
                return View();
            }

            formsAuth.SignIn(user.Login, input.Remember, user.Roles.Select(o => o.Name));

            return RedirectToAction("index", "dinner");
        }