예제 #1
0
        public IActionResult Login(User user)
        {
            var  repository = new QuestionsRepository(_conn);
            User u          = repository.GetUser(user);

            if (u == null)
            {
                return(Redirect("/account/login"));
            }

            else if (!repository.Match(user.Password, u.Password))
            {
                return(Redirect("/account/login"));
            }

            var claims = new List <Claim>
            {
                new Claim("user", user.Email)
            };

            HttpContext.SignInAsync(new ClaimsPrincipal(
                                        new ClaimsIdentity(claims, "Cookies", "user", "role"))).Wait();


            return(Redirect("/home/index"));
        }