示例#1
0
        public virtual ActionResult Login(LoginModel loginModel)
        {
            if (ModelState.IsValid)
            {
                if (MSExchangeHelper.Login(loginModel))
                {
                    var isAuthentificated = FormsAuthenticationHelper.Login(loginModel.Email, loginModel.Password, loginModel.IsPersistent);
                    if (isAuthentificated)
                    {
                        if (!string.IsNullOrEmpty(loginModel.ReturnUrl))
                        {
                            return(Redirect(loginModel.ReturnUrl));
                        }

                        return(RedirectToAction(MVC.Home.Index()));
                    }

                    ModelState.AddModelError(string.Empty, Constants.LoginorPasswordisUncorrectErrorMessage);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, Constants.UncorrectDataforEnrtytotheSystemofClientMSExchangeErrorMessage);
                }

                return(View(loginModel));
            }

            return(View(loginModel));
        }