public ActionResult Logout() { IAdminUserInfoService adminUserInfoService = StructureMap.ObjectFactory.GetInstance <IAdminUserInfoService>(); adminUserInfoService.Logout(); return(RedirectToAction("Index", "Home")); }
protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!base.IsLogined(httpContext)) { return(false);//未登录 } var result = base.AuthorizeCore(httpContext); if (result) { if (!httpContext.Request.IsLocal) { var adminSession = httpContext.Session["AdminLogin"] as string; if (adminSession.IsNullOrEmpty()) { try { IAdminUserInfoService userInfoService = StructureMap.ObjectFactory.GetInstance <IAdminUserInfoService>(); userInfoService.Logout(); //强制退出登录 } catch { } result = false; } } } return(result); }
public InstallController(ISystemConfigService systemConfigService, IAdminUserInfoService adminUserInfoService) { _adminUserInfoService = adminUserInfoService; _systemConfigService = systemConfigService; }
public AdminUserInfoController(IAdminUserInfoService adminUserInfoService) { this._adminUserInfoService = adminUserInfoService; }
public LayUiAdminLoginController() { _adminUserInfoService = new AdminUserInfoService(); _currentWebContext = InstanceManger.GetCurrentWebContext();; }
public CurrentWebContext() { _adminUserInfoService = new AdminUserInfoService(); _timeOut = FormsAuthentication.Timeout; }
//[ValidateAntiForgeryToken] public ActionResult Index(Login_IndexVD vdForm) { //this.Validator(vdForm.Checkcode, "验证码", "Checkcode", null).ValidateCheckCode(CheckCodeKind.Login, true); //验证域名 string errorMsg = null; IAdminUserInfoService adminUserInfoService = null; AdminUserInfo adminUserInfo = null; if (vdForm.UserName.IsNullOrEmpty()) { errorMsg = "请填写账号!"; } else if (vdForm.Password.IsNullOrEmpty()) { errorMsg = "请填写密码!"; } else { if (Session["TryLoginTimes"] != null) { //TODO:验证码 } if (ModelState.IsValid) { adminUserInfoService = StructureMap.ObjectFactory.GetInstance <IAdminUserInfoService>(); adminUserInfo = adminUserInfoService.GetUserInfo(vdForm.UserName); if (adminUserInfo == null) { errorMsg = "账号或密码错误!错误代码:101。"; } //else if (userInfo.Locked) //{ // errorMsg = "账号已被锁定,无法登录。"; //} else if (adminUserInfoService.TryLogin(vdForm.UserName, vdForm.Password, true) == null) { errorMsg = "账号或密码错误!错误代码:102。"; } } } if (!errorMsg.IsNullOrEmpty() || !ModelState.IsValid) { var tryLoginTimes = 0; if (Session["TryLoginTimes"] != null) { tryLoginTimes = (int)Session["TryLoginTimes"]; } vdForm.ShowCheckCode = tryLoginTimes >= SiteConfig.TryLoginTimes; Session["TryLoginTimes"] = tryLoginTimes + 1; vdForm.MessagerList = new List <Messager>(); vdForm.MessagerList.Add(new Messager(Core.Enums.MessageType.error, errorMsg)); return(View(vdForm)); } Session["TryLoginTimes"] = null;//清空登录次数 LogUtility.AdminUserInfo.InfoFormat("用户登录成功:{0}", vdForm.UserName); Session["AdminLogin"] = "******"; if (vdForm.ReturnUrl.IsNullOrEmpty()) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(vdForm.ReturnUrl.UrlDecode())); } }
public LayUiSystemController() { _currentWebContext = InstanceManger.GetCurrentWebContext(); _adminUserInfoService = new AdminUserInfoService(); }
public LayUiAdminUserInfoController() { _adminUserInfoService = new AdminUserInfoService(); }