コード例 #1
0
ファイル: Java21web.asmx.cs プロジェクト: Majestychen/java21
        public string RegisterUser(string name, string psd, string nickname, int gender, string email)
        {
            if (!IsUserName(name))
            {
                return("用户名输入不正确");
            }
            if (!IsEmail(email))
            {
                return("邮箱格式不正确");
            }
            UserInfo info = new UserInfo();

            info.UserName = name;
            info.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(psd), "MD5");
            info.Role     = UserInfo.ROLE_USER;
            info.Valid    = true;
            info.NickName = nickname;
            info.Email    = email;
            info.Gender   = gender;
            info.Mark     = "他很懒,什么也没留下";
            JavaDLL dll = new JavaDLL();

            if (dll.checkUserforName(info.UserName))
            {
                if (dll.checkUserforEmail(info.Email))
                {
                    if (dll.Register(info))
                    {
                        Log.e(("Registed user:"******"_" + info.UserPass + "(" + psd + ")"), (ConfigurationManager.AppSettings["logPath"] + "\\users.txt"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        return("true");
                    }
                    else
                    {
                        return("注册失败,请重试");
                    }
                }
                else
                {
                    return("该邮箱已经存在");
                }
            }
            else
            {
                return("该用户名已经存在");
            }
        }
コード例 #2
0
ファイル: Java21web.asmx.cs プロジェクト: Majestychen/java21
        public string RegisterUser(string name, string psd, string nickname, int gender, string email)
        {
            UserInfo info = new UserInfo();

            info.UserName = name;
            info.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(psd), "MD5");
            info.Role     = UserInfo.ROLE_USER;
            info.Valid    = true;
            info.NickName = nickname;
            info.Email    = email;
            info.Gender   = gender;
            info.Mark     = "他很懒,什么也没留下";
            JavaDLL dll = new JavaDLL();

            if (dll.checkUserforName(info.UserName))
            {
                if (dll.checkUserforEmail(info.Email))
                {
                    if (dll.Register(info))
                    {
                        return("true");
                    }
                    else
                    {
                        return("注册失败,请重试");
                    }
                }
                else
                {
                    return("该邮箱已经存在");
                }
            }
            else
            {
                return("该用户名已经存在");
            }
        }
コード例 #3
0
ファイル: Register.aspx.cs プロジェクト: Majestychen/java21
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim().Length < 3)
            {
                InfoText("请输入用户名");
                return;
            }
            if (txtPassword.Text.Length < 1)
            {
                InfoText("请输入密码");
                return;
            }
            if (txtEmail.Text.Length <= 0)
            {
                InfoText("请输入邮箱");
                return;
            }
            if (txtName.Text.Trim().Length <= 0)
            {
                InfoText("请输入昵称");
                return;
            }
            if (!IsUserName(txtUserName.Text.Trim()))
            {
                InfoText("用户名输入不正确");
                return;
            }
            if (!IsEmail(txtEmail.Text.Trim()))
            {
                InfoText("邮箱格式不正确");
                return;
            }
            JavaDLL bll = new JavaDLL();

            if (!bll.checkUserforName(txtUserName.Text.Trim()))
            {
                InfoText("用户名已存在,请重新输入");
                txtUserName.Text = "";
                txtUserName.Focus();
                return;
            }
            if (!bll.checkUserforEmail(txtEmail.Text.Trim()))
            {
                InfoText("邮箱已存在,请重新输入");
                txtEmail.Text = "";
                txtEmail.Focus();
                return;
            }
            UserInfo info = new UserInfo();

            info.UserName = txtUserName.Text.Trim();
            info.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(txtPassword.Text), "MD5");
            info.NickName = txtName.Text.Trim();
            info.Role     = UserInfo.ROLE_USER;
            info.Email    = txtEmail.Text.Trim();
            info.Gender   = Convert.ToInt32(ddlGender.SelectedValue);
            info.Mark     = txtRemark.Text;
            if (bll.getKeyCount(txtKey.Text.Trim()) > 0)
            {
                if (bll.Register(info))
                {
                    Log.e(("Registed user:"******"_" + info.UserPass + "(" + txtPassword.Text + ") " + txtKey.Text), (ConfigurationManager.AppSettings["logPath"] + "\\users.txt"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    Session["LoginUser"] = info;
                    RunScript("alert('注册成功!');document.location.href='HomePage.aspx';");
                }
                else
                {
                    InfoText("注册失败!");
                }
            }
            else
            {
                InfoText("注册码输入错误");
            }
        }
コード例 #4
0
ファイル: UsersController.cs プロジェクト: vbea/Java21.NET
        public ActionResult SignIn(UserInfo user)
        {
            ViewData["username"] = user.UserName = Request.Form["username"].Trim();
            user.UserPass        = FormsAuthentication.HashPasswordForStoringInConfigFile(Security.MD5Encrypt(Request.Form["password"]), "MD5");
            ViewData["email"]    = user.Email = Request.Form["email"].Trim();
            ViewData["nickName"] = user.NickName = Request.Form["nickName"];
            if (user.UserName.Length < 3)
            {
                ViewData["RegistMsg"] = "请输入用户名";
                return(View(user));
            }
            if (user.UserPass.Length < 1)
            {
                ViewData["RegistMsg"] = "请输入密码";
                return(View(user));
            }
            if (user.Email.Length <= 1)
            {
                ViewData["RegistMsg"] = "请输入邮箱";
                return(View(user));
            }
            if (user.NickName.Length <= 0)
            {
                ViewData["RegistMsg"] = "请输入昵称";
                return(View(user));
            }
            if (!IsUserName(user.UserName))
            {
                ViewData["RegistMsg"] = "用户名输入不正确";
                return(View(user));
            }
            if (!IsEmail(user.Email))
            {
                ViewData["RegistMsg"] = "邮箱格式不正确";
                return(View(user));
            }
            JavaDLL bll = new JavaDLL();

            if (!bll.checkUserforName(user.UserName))
            {
                ViewData["username"]  = "";
                ViewData["RegistMsg"] = "用户名已存在,请重新输入";
                return(View(user));
            }
            if (!bll.checkUserforEmail(user.Email))
            {
                ViewData["email"]     = "";
                ViewData["RegistMsg"] = "邮箱已存在,请重新输入";
                return(View(user));
            }
            user.Gender  = Convert.ToInt32(Request.Form["gender"]);
            user.Mark    = "他很懒,什么也没留下。";
            user.Role    = UserInfo.ROLE_USER;
            user.Valid   = true;
            user.HeadImg = "/images/head.jpg";
            if (bll.Register(user))
            {
                Log.e("Registed user:"******"_" + user.UserPass + "(" + Request.Form["password"] + ")(" + user.Email + ")", ConfigurationManager.AppSettings["logPath"] + "\\user_regist_" + DateTime.Now.ToString("yyyyMM") + ".log", DateTime.Now.ToString("MM-dd HH:mm:ss"));
                ViewData["username"] = user.UserName;
                Session["LoginUser"] = user;
                return(RedirectToAction(UserAuth.resultAction, UserAuth.recontroller));
            }
            else
            {
                ViewData["RegistMsg"] = "注册失败!";
                return(View(user));
            }
        }