Beispiel #1
0
        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());
        }