Ejemplo n.º 1
0
        public ResponseStatus Login(HttpRequestBase req, Container_List_Status conTa_status, ref UserStatus us)
        {
            if (req.Form.Count == 0)
            {
                return ResponseStatus.REQFORM_COUNT_ISZERO;
            }
            else
            {
                string message = "";
                VerifyUtil2 verify2 = new VerifyUtil2();
                conTa_status.list_ErrMsg = new List<string>();
                conTa_status.user = new UserStatus();

                string userID = req.Form["userID"].ToString();
                Rule[] rules = new Rule[] { Rule.REQUEST, Rule.DIGIT, Rule.LENGTH };
                if (!verify2.Verify("学号", userID, rules, 10,10 , out message))
                {
                    conTa_status.list_ErrMsg.Add(message);
                }
                else
                {
                    conTa_status.user.UserID = userID;
                }

                string pwd = req.Form["pwd"].ToString();
                rules = new Rule[] { Rule.REQUEST, Rule.DIGITABC, Rule.LENGTH };
                if (!verify2.Verify("密码", pwd, rules, 8, 16, out message))
                {
                    conTa_status.list_ErrMsg.Add(message);
                }
                else
                {
                    pwd = MD5Factory.Instance().GetMd5Hash(pwd);
                    conTa_status.user.Password = pwd;
                }

                if (conTa_status.list_ErrMsg.Count == 0)
                {
                    conTa_status.list_ErrMsg = null;
                    UserDAL userDAL = new UserDAL();
                    ResponseStatus resp = userDAL.Login(userID, pwd, ref us);
                    userDAL.ReturnUnitToPool();
                    return resp;
                }
                else
                {
                    return ResponseStatus.LOGIN_FAILED;
                }
            }
        }