Exemple #1
0
        /// <summary>
        /// 登录验证码
        /// </summary>
        public void VerifyCode_GET()
        {
            string     word = null;
            VerifyCode v    = new VerifyCode();
            var        font = v.GetDefaultFont();

            try
            {
                font          = new System.Drawing.Font(font.FontFamily, 16);
                v.AllowRepeat = false;
                Response.BinaryWrite(v.GraphicDrawImage(4,
                                                        VerifyWordOptions.Letter,
                                                        !true,
                                                        font,
                                                        60,
                                                        out word));
            }
            catch
            {
                if (font != null)
                {
                    font.Dispose();
                }
            }
            Response.ContentType = "Image/Jpeg";
            VerifyCodeManager.AddWord(word);
        }
Exemple #2
0
        /// <summary>
        /// 登录提交
        /// </summary>
        public void Login_POST()
        {
            string username   = base.Request.Form["uid"],
                   password   = base.Request.Form["pwd"],
                   verifycode = base.Request.Form["code"];

            if (!VerifyCodeManager.Compare(verifycode))
            {
                base.RenderError("验证码不正确");
            }
            else
            {
                //设置站点
                User usr = CmsLogic.User.GetUser(username, password);

                if (usr != null)
                {
                    CmsLogic.User.UpdateUserLastLoginDate(username);

                    if (!usr.Available)
                    {
                        base.RenderError("账号已被停用,请联系管理员!");
                    }
                    else
                    {
                        //保存登陆信息
                        bool result = UserState.Administrator.Login(username, password, 3600 * 120);

                        //验证站点信息
                        if (usr.SiteId > 0)
                        {
                            SiteDto site = SiteCacheManager.GetSite(usr.SiteId);
                            if (!(site.SiteId > 0))
                            {
                                base.RenderError("账号已被停用,请联系管理员!");
                                return;
                            }
                            base.CurrentSite = site;
                        }
                        base.RenderSuccess();
                    }
                }
                else
                {
                    base.RenderError("账户或密码不正确!");
                }
            }
        }