Ejemplo n.º 1
0
        public ActionResult AddRegisterUser()
        {
            string   userName = Request["LoginUserName"];
            string   password = Request["LoginPwd"];
            UserInfo exist    = userInfoService.LoadEntities(s => s.Name == userName).FirstOrDefault();

            if (exist != null)
            {
                return(Content("注册失败,用户名已被占用"));
            }
            UserInfo userInfo = new UserInfo();

            userInfo.Name     = userName;
            userInfo.Password = MD5Encrypt.EncryptString(password);
            UserInfo user = userInfoService.AddEntity(userInfo);

            if (user != null)
            {
                InitUserAccount(user);
                return(Content("ok"));
            }
            else
            {
                return(Content("注册失败"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult UserLogin()
        {
            string   userName = Request["LoginUserName"];
            string   password = MD5Encrypt.EncryptString(Request["LoginPwd"]);
            UserInfo user     = userInfoService.LoadEntities(s => s.Name == userName && s.Password == password).FirstOrDefault();

            if (user == null)
            {
                return(Content("用户名或密码错误!"));
            }
            else
            {
                FormsAuthentication.SetAuthCookie(userName, false);
                Session["userInfo"] = user;
                return(Content("ok"));
            }
        }