コード例 #1
0
        public IActionResult Login([Bind] User user)
        {
            string staticSalt = "hdT6deKj65TTu+e44EBHDCyDd34RR+33ExafdEFFDhv=";
            string login      = user.UserName + "|" + user.Password;
            string hashedPW   = SecurityFactory.hashString(login, staticSalt);

            if (hashedPW == Configuration["User"])
            {
                var userClaims = new List <Claim>()
                {
                    new Claim(ClaimTypes.Name, user.UserName),
                };

                var identity = new ClaimsIdentity(userClaims, "User Identity");

                var userPrincipal = new ClaimsPrincipal(new[] { identity });
                HttpContext.SignInAsync(userPrincipal);

                return(RedirectToAction("Dashboard", "Xfer"));
            }

            ViewBag.Message = "UserName and Password combination is incorrect";
            return(View());
        }