Esempio n. 1
0
        private void btnRegist_Click(object sender, EventArgs e)
        {
            if (WebSocketManager.IsConnected() == false)
            {
                WebSocketManager.InitWebSocket();
                if (WebSocketManager.IsConnected() == false)
                {
                    string tips = string.Format("无法连接服务器,请确保服务器地址为{0},且处于开启状态", AppValues.SERVER_URL);
                    MessageBox.Show(this, tips, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            string inputUsername = txtUsername.Text.Trim();
            string inputPassword = txtPassword.Text.Trim();

            if (string.IsNullOrEmpty(inputUsername))
            {
                MessageBox.Show("用户名不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(inputPassword))
            {
                MessageBox.Show("密码不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            RegistRequest.Builder builder = RegistRequest.CreateBuilder();
            builder.SetUsername(inputUsername);
            builder.SetPassword(inputPassword);
            WebSocketManager.SendMessage(RpcNameEnum.Regist, builder.Build().ToByteArray(), OnRegistCallback);
        }
Esempio n. 2
0
    private void Start()
    {
        usernameIF    = transform.Find("UsernameLabel/UsernameInput").GetComponent <InputField>();
        passwordIF    = transform.Find("PasswordLabel/PasswordInput").GetComponent <InputField>();
        repasswordIF  = transform.Find("RePasswordLabel/RePasswordInput").GetComponent <InputField>();
        registRequest = GetComponent <RegistRequest>();

        transform.Find("RegistButton").GetComponent <Button>().onClick.AddListener(OnRegsitButtonClick);
        transform.Find("CloseButton").GetComponent <Button>().onClick.AddListener(OnCloseButtonClick);
    }
Esempio n. 3
0
 //把member类型的证书加载到org下面的peer节点
 public override Task <RegistReply> Regist(RegistRequest request, ServerCallContext context)
 {
     try
     {
         if (_identityProvider.GetCAUserName() != request.Username ||
             _identityProvider.GetCAPassword() != request.Password)
         {
             return(Task.FromResult(new RegistReply()
             {
                 Status = false
             }));
         }
         //获取证书
         var ca = Newtonsoft.Json.JsonConvert.DeserializeObject <Certificate>(request.Certificate);
         //校验签名
         var rs = RSAHelper.VerifyData(_identityProvider.GetPublicKey(), ca.TBSCertificate, ca.SignatureValue);
         //如果是peer节点类型 则返回false
         //peer节点类型在组织加入通道的时候进行校验
         if (ca.TBSCertificate.CAType == CAType.Peer)
         {
             return(Task.FromResult(new RegistReply()
             {
                 Status = false,
                 Msg = "签名校验失败"
             }));
         }
         else
         {
             //把证书上链
             var caconfig = new OrgMemberConfig();
             caconfig.Name        = ca.TBSCertificate.Subject;
             caconfig.OrgId       = _identityProvider.GetPeerIdentity().OrgId;
             caconfig.Certificate = ca;
             var response = _invokeBLL.RegistMember(request.ChannelId, caconfig);
             return(Task.FromResult(new RegistReply()
             {
                 Status = true,
                 Msg = "注册成功!"
             }));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, ex.Message);
         return(Task.FromResult(new RegistReply()
         {
             Status = false,
             Msg = ex.Message
         }));
     }
 }
Esempio n. 4
0
 public override void InitStart()
 {
     Input_UserName            = gameObject.transform.Find("UserName/Input_UserName").GetComponent <InputField>();
     Txt_UserNamePlaceholder   = gameObject.transform.Find("UserName/Input_UserName/Txt_UserNamePlaceholder").GetComponent <Text>();
     Txt_UserNameText          = gameObject.transform.Find("UserName/Input_UserName/Txt_UserNameText").GetComponent <Text>();
     Input_PassWord            = gameObject.transform.Find("PassWord/Input_PassWord").GetComponent <InputField>();
     Txt_PassWordPlaceholder   = gameObject.transform.Find("PassWord/Input_PassWord/Txt_PassWordPlaceholder").GetComponent <Text>();
     Txt_PassWordText          = gameObject.transform.Find("PassWord/Input_PassWord/Txt_PassWordText").GetComponent <Text>();
     Btn_Register              = gameObject.transform.Find("Btn_Register").GetComponent <Button>();
     Input_RePassWord          = gameObject.transform.Find("RePassWord/Input_RePassWord").GetComponent <InputField>();
     Txt_RePassWordPlaceholder = gameObject.transform.Find("RePassWord/Input_RePassWord/Txt_RePassWordPlaceholder").GetComponent <Text>();
     Txt_RePassWordText        = gameObject.transform.Find("RePassWord/Input_RePassWord/Txt_RePassWordText").GetComponent <Text>();
     Btn_Close     = gameObject.transform.Find("Btn_Close").GetComponent <Button>();
     registRequest = GetComponent <RegistRequest>();
     AddClicks();
 }
        public JsonResult RegistRequest(RegistRequest regist)
        {
            Result registresult = new Result()
            {
                Status     = true,
                Message    = "账户注册成功,请到邮箱进行验证.",
                StatusCode = "RR100"
            };

            string lastdate = CookieUtils.Get("lastSubmit");

            if (string.IsNullOrEmpty(lastdate))
            {
                CookieUtils.SetCookie("lastSubmit", DateTime.Now.ToString());
            }
            else
            {
                DateTime now = DateTime.Now;
                CookieUtils.SetCookie("lastSubmit", now.ToString());
                double seconds = now.Subtract(Convert.ToDateTime(lastdate)).TotalMilliseconds;
                if (seconds < 1000 * 5)
                {
                    registresult.Status     = false;
                    registresult.Message    = "操作过于频繁,请稍后再试";
                    registresult.StatusCode = "RR000";
                }
            }

            if (registresult.Status)
            {
                IAccountService  service       = ServiceObjectContainer.Get <IAccountService>();
                Result <Account> accountresult = service.RegistInfo(regist);
                if (!accountresult.Status)
                {
                    registresult.Status     = false;
                    registresult.Message    = "注册账户失败,请稍后再试";
                    registresult.StatusCode = "RR001";
                }
                else
                {
                    service.SendRegistEmail(accountresult.Data);
                }
            }
            return(Json(registresult));
        }
Esempio n. 6
0
        /// <summary>
        /// 注册账户信息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public Result <Account> RegistInfo(RegistRequest request)
        {
            Result <Account> result = new Result <Account>()
            {
                Status     = true,
                Message    = "注册账户成功",
                Data       = null,
                StatusCode = "RR000"
            };

            AccountInfo account = new AccountInfo();

            account.Phone          = Int64.Parse(request.Phone);
            account.Email          = request.Email;
            account.SecurityCode   = MD5Engine.ToMD5String(request.SecurityCode);
            account.CreatDate      = DateTime.Now;
            account.BirthdayDate   = DateTime.Parse("2000-01-01");
            account.Avator         = ConstInfo.DefaultHeadBase64;
            account.BackCorver     = ConstInfo.DefaultBackCover;
            account.Sex            = Model.Enum.AccountSex.Male.GetHashCode();
            account.RequiredStatus = Model.Enum.AccountRequiredStatus.UnRequired.GetHashCode();
            account.Description    = "";
            account.NickName       = request.Phone;


            //加入数据库
            try
            {
                IAccountInfoCache service = ServiceObjectContainer.Get <IAccountInfoCache>();

                if (service.SearchInfoByKey(account.GetKeyName()) == null)
                {
                    //入库
                    result.Status = DBConnectionManager.Instance.Writer.Insert(new AccountAddSpefication(account).Satifasy());

                    if (result.Status)
                    {
                        DBConnectionManager.Instance.Writer.Commit();
                        //加入缓存
                        service.SaveInfo(account);
                        result.Data = account.Copy <Account>();
                    }
                }
                else
                {
                    result.Status     = false;
                    result.Message    = "当前账户已存在";
                    result.StatusCode = "RR001";
                }
            }
            catch (Exception ex)
            {
                DBConnectionManager.Instance.Writer.Rollback();
                result.Status     = false;
                result.Message    = ex.Message;
                result.StatusCode = "EX000";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:RegistInfo() .AccountService"), LogType.ErrorLog);
            }


            return(result);
        }