Esempio n. 1
0
        public ActionResult Logout()
        {
            IAdminUserInfoService adminUserInfoService = StructureMap.ObjectFactory.GetInstance <IAdminUserInfoService>();

            adminUserInfoService.Logout();
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public InstallController(ISystemConfigService systemConfigService, IAdminUserInfoService adminUserInfoService)
 {
     _adminUserInfoService = adminUserInfoService;
     _systemConfigService  = systemConfigService;
 }
Esempio n. 4
0
 public AdminUserInfoController(IAdminUserInfoService adminUserInfoService)
 {
     this._adminUserInfoService = adminUserInfoService;
 }
 public LayUiAdminLoginController()
 {
     _adminUserInfoService = new AdminUserInfoService();
     _currentWebContext    = InstanceManger.GetCurrentWebContext();;
 }
Esempio n. 6
0
 public CurrentWebContext()
 {
     _adminUserInfoService = new AdminUserInfoService();
     _timeOut = FormsAuthentication.Timeout;
 }
Esempio n. 7
0
        //[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();
 }
Esempio n. 9
0
 public LayUiAdminUserInfoController()
 {
     _adminUserInfoService = new AdminUserInfoService();
 }