public ActionResult Index(LoginModel model) { try { if (ModelState.IsValid) { var user = _accessTokenService.GetUser(model); if (user == null) { return(View().WithError("Invalid email address and password.")); } _setupUser.SetupUserDetail(Convert.ToInt32(user.Id), user); Session["StoreId"] = Request["Stores"].ToString(); if (model.RememberMe) { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30); Response.Cookies["UserName"].Value = model.Email; Response.Cookies["Password"].Value = model.Password; } return(RedirectToAction("Index", "CustomerShopView")); } } catch (Exception ex) { _log.ErrorFormat("Following error occured while getting web user info : {0}", ex.Message); _log.Error(ex.Message); return(View(model)); } return(View()); }
public ActionResult Index(LoginModel model) { try { if (ModelState.IsValid) { var sessionUser = _accessTokenService.GetWebUser(model); if (sessionUser == null) { return(View().WithError("Nom d'usuari i contrasenya no vàlids.")); } _setupUser.SetupUserDetail(Convert.ToInt32(sessionUser.Id), sessionUser); if (model.RememberMe) { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30); Response.Cookies["UserName"].Value = model.Email; Response.Cookies["Password"].Value = model.Password; } return(RedirectToAction("Index", "Dashboard")); } else { return(View()); } } catch (Exception ex) { _log.ErrorFormat("Following error occured while getting web user info : {0}", ex.Message); _log.Error(ex.Message); return(View(model)); } }