コード例 #1
0
ファイル: AccountController.cs プロジェクト: NoCat/mp
        public ActionResult Signup(string email, string name, string password1, string password2)
        {
            var result = new AjaxResult();

            if (password1 != password2)
            {
                result.Success = false;
                result.Message = "两次输入的密码不一样";
                return JsonContent(result);
            }

            email = email.Trim();
            var emailExist = Manager.Users.Items.Where(u => u.Email == email).Count() > 0;
            if (emailExist)
            {
                result.Success = false;
                result.Message = "邮箱已使用";
                return JsonContent(result);
            }

            name = name.Trim();
            var nameExist = Manager.Users.Items.Where(u => u.Name == name).Count() > 0;
            if (nameExist)
            {
                result.Success = false;
                result.Message = "昵称已使用";
                return JsonContent(result);
            }

            var salt = Guid.NewGuid().ToByteArray().ToHexString();
            var password = (password1 + salt).MD5();

            var user = new User
            {
                Name = name,
                Email = email,
                Password = password,
                Salt = salt,
                UseDefaultHead=true
            };

            Manager.Users.Add(user);

            return JsonContent(result);
        }
コード例 #2
0
ファイル: UserInfo.cs プロジェクト: NoCat/mp
 public UserInfo(User user)
 {
     ID = user.ID;
     Email = user.Email;
     Name = user.Name;
 }