public JsonResult Login(LoginModel model) { GoToViewModel gotoViewModel = new GoToViewModel(); gotoViewModel.Url = WebBackConfig.GetLoginPage(); LoginManager <SysStaffUser> loginWebBack = new LoginManager <SysStaffUser>(); var result = loginWebBack.SignIn(model.UserName, model.Password, CommonUtils.GetIP(), Enumeration.LoginType.Website); if (result.ResultType == Enumeration.LoginResult.Failure) { if (result.ResultTip == Enumeration.LoginResultTip.UserNotExist || result.ResultTip == Enumeration.LoginResultTip.UserPasswordIncorrect) { return(Json(ResultType.Failure, gotoViewModel, WebBackOperateTipUtils.LOGIN_USERNAMEORPASSWORDINCORRECT)); } if (result.ResultTip == Enumeration.LoginResultTip.UserDisabled) { return(Json(ResultType.Failure, gotoViewModel, WebBackOperateTipUtils.LOGIN_ACCOUNT_DISABLED)); } if (result.ResultTip == Enumeration.LoginResultTip.UserDeleted) { return(Json(ResultType.Failure, gotoViewModel, WebBackOperateTipUtils.LOGIN_ACCOUNT_DELETE)); } } gotoViewModel.Url = WebBackConfig.GetHomePage(); return(Json(ResultType.Success, gotoViewModel, WebBackOperateTipUtils.LOGIN_SUCCESS)); }
public ActionResult Login() { //SmsHelper.Send("SMS_44380432", "{\"customer\":\"邱庆文\"}", "15989287032"); Session["WebBackLoginVerifyCode"] = null; if (Request.IsAuthenticated) { if (Request.QueryString["out"] == null) { return(Redirect(WebBackConfig.GetHomePage())); } } return(View()); }
void IExceptionFilter.OnException(ExceptionContext filterContext) { ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); bool isAjaxRequest = filterContext.RequestContext.HttpContext.Request.IsAjaxRequest(); string controller = (string)filterContext.RouteData.Values["controller"]; string action = (string)filterContext.RouteData.Values["action"]; MessageBoxModel messageBox = new MessageBoxModel(); messageBox.No = Guid.NewGuid().ToString(); messageBox.Type = MessageBoxTip.Exception; messageBox.Title = "抱歉,访问出错"; messageBox.Content = "<a href=\"javascript:void(0)\" onclick=\"window.top.location.href='" + WebBackConfig.GetHomePage() + "'\">返回主页</a>"; messageBox.IsTop = true; if (WebBackConfig.CanViewErrorStackTrace()) { messageBox.ErrorStackTrace = CommonUtils.ToHtml(filterContext.Exception.Message + "\r\n" + filterContext.Exception.StackTrace); } //判断是否异步调用 if (isAjaxRequest) { CustomJsonResult jsonResult = new CustomJsonResult(ResultType.Exception, ResultCode.Exception, messageBox.Title, messageBox); jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; filterContext.Result = jsonResult; filterContext.Result.ExecuteResult(filterContext); filterContext.HttpContext.Response.End(); } else { string masterName = "_LayoutHome"; if (filterContext.HttpContext.Request.QueryString["dialogtitle"] != null) { masterName = "_Layout"; } filterContext.Result = new ViewResult { ViewName = "MessageBox", MasterName = masterName, ViewData = new ViewDataDictionary { Model = messageBox } }; } filterContext.ExceptionHandled = true; log.Error("发生异常错误[编号:" + messageBox.No + "]", filterContext.Exception); }