예제 #1
0
        public JsonResult Authentications(string UserName, string Password)
        {
            AuthenticationBL obj    = new AuthenticationBL(_context, _httpContextAccessor);
            bool             result = obj.AuthenticateUser(UserName, Password);

            return(Json(result));
        }
예제 #2
0
        public ActionResult Login(EmployeeModel emp)
        {
            if (ModelState.IsValid)
            {
                bool IsUserAuthenticated = authBusiness.AuthenticateUser(
                    new Models.Employee
                {
                    Password = emp.Password,
                    UserName = emp.UserName
                }
                    );
                if (IsUserAuthenticated)
                {
                    Session["Name"]    = "Tim Ryan";
                    Session["Address"] = "London,UK";
                    FormsAuthentication.SetAuthCookie(emp.UserName, false);
                    return(RedirectToAction("Index", "Employee"));
                }
                ViewBag.ErrorMessage = "Provided username or password is invalid";
            }

            return(View());
        }