public static Purchaser getAuthoriz(string username, string password, DBAgent.DBAgent agent)
        {
            Purchaser purchaser = null;

            if (agent.CheckAuthoriz(username, password))
            {
                purchaser = agent.getPurchaser(username, password);
            }
            return(purchaser);
        }
Beispiel #2
0
 public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
 {
     using (DBAgent.DBAgent agent = new DBAgent.DBAgent())
     {
         getAuthorize();
         if (agent.CheckAuthoriz(model.Email, model.Password))
         {
             HttpContext.Response.Cookies["username"].Value    = model.Email;
             HttpContext.Response.Cookies["ifAuthorize"].Value = true.ToString();
             return(Redirect("/Home/Index"));
         }
         else
         {
             ModelState.AddModelError("", "Неудачная попытка входа.");
             return(View(model));
         }
     }
 }