Beispiel #1
0
 public IActionResult Login(string username, string password)
 {
     context = HttpContext.RequestServices.GetService(typeof(BCare.data.BcareContext)) as BcareContext;
     if (context.Login(username, password))
     {
         CookieOptions options = new CookieOptions();
         options.Expires = DateTime.Now.AddDays(30);
         Response.Cookies.Append("Session", RandomString(10) + context.GetIDByUserName(username), options);
         Response.Cookies.Append("UserName", username, options);
     }
     else
     {
         TempData["errorMessage"] = "שם המשתמש או הסיסמה לא תקינים";
     }
     return(RedirectToAction("Index"));
 }