Exemple #1
0
        public ActionResult UserYesNoCode()
        {
            string validatecode = this.Request.Form["param"];
            bool   isCodeYesNo  = (NTool.IsSessionEquals(NModel.EnObject.UserCodeSessionName, validatecode));

            if (!isCodeYesNo)
            {
                this.Response.Write("{ \"info\":\"验证码不正确\", \"status\":\"n\" }");
            }
            else
            {
                this.Response.Write("{ \"info\":\"验证码已通验证\", \"status\":\"y\" }");
            }
            return(View());
        }
Exemple #2
0
        public bool CheckLogin(string name, string pw, string code)
        {
            if (NTool.IsSessionEquals(NModel.EnObject.CaptchaSessionName, code))
            {
                NCaptcha.Generate(true);

                NModel.Admin_User cModel_User = this.ExistsNamePw((name + "").ToLower(), NMd5.GetMd5Hash(pw).ToLower());
                if (cModel_User != null && cModel_User.User_ID > 0)
                {
                    HttpContext.Current.Session[NModel.EnObject.LoginSessionName]        = cModel_User.User_Name;
                    HttpContext.Current.Session[NModel.EnObject.CurrentLoginSessionName] = cModel_User;

                    BLL.DB_Session    cModel         = new DB_Session();
                    NModel.DB_Session cModel_Session = new NModel.DB_Session();
                    cModel_Session.Session_DB_Name = base.TableName;
                    cModel_Session.Session_UserID  = cModel_User.User_ID;

                    cModel_Session.Session_CID     = (HttpContext.Current.Session.SessionID + "");
                    cModel_Session.Session_Status  = 1;
                    cModel_Session.Session_EndTime = DateTime.Parse(DateTime.Now.AddHours(60).ToString("s"));
                    ///DateTime.Parse(DateTime.Now.AddHours(60).ToString("yyyy-MM-dd hh:mm:ss"));
                    cModel_Session.Session_AddTime = DateTime.Parse(DateTime.Now.ToString("s"));

                    if (cModel.Add(cModel_Session) > 0)
                    {
                        cModel.Close();

                        Tool.NTool.AddCookie(base.TableName, cModel_Session.Session_CID + "_" + cModel_User.User_ID, 60);
                        return(true);
                    }
                    ;
                    cModel.Close();
                }
            }

            return(false);
        }