public async Task <IHttpActionResult> Convert([FromBody] AccountConvertInfo info) { Logger.Info($"Account.Convert AccountName={info.AccountName}"); var account = await GetAndVerifyAccount(info.AccountId); if (!EncryptHashManager.VerifyHash(info.OldPassword, account.Password)) { await this.RecordLogin(account, UCenterErrorCode.AccountLoginFailedPasswordNotMatch, "The account name and password do not match"); throw new UCenterException(UCenterErrorCode.AccountLoginFailedPasswordNotMatch); } account.AccountName = info.AccountName; account.IsGuest = false; account.Name = info.Name; account.IdentityNum = info.IdentityNum; account.Password = EncryptHashManager.ComputeHash(info.Password); account.SuperPassword = EncryptHashManager.ComputeHash(info.SuperPassword); account.PhoneNum = info.PhoneNum; account.Email = info.Email; account.Sex = info.Sex; await this.DatabaseContext.Bucket.UpsertSlimAsync(account); await this.RecordLogin(account, UCenterErrorCode.Success, "Account converted successfully."); return(CreateSuccessResult(ToResponse <AccountRegisterResponse>(account))); }
public async Task E2E_AppClient_Guest_Login_And_Convert_Test() { var loginResponse = await cClient.AccountGuestLoginAsync(); Assert.IsNotNull(loginResponse.AccountId); Assert.IsNotNull(loginResponse.AccountName); Assert.IsNotNull(loginResponse.Password); Assert.IsNotNull(loginResponse.Token); var convertInfo = new AccountConvertInfo { AccountId = loginResponse.AccountId, AccountName = GenerateRandomString(), OldPassword = loginResponse.Password, Password = ValidAccountPassword, SuperPassword = ValidAccountPassword, Name = GenerateRandomString(), PhoneNum = GenerateRandomString(), Email = GenerateRandomString(), IdentityNum = GenerateRandomString(), Sex = Sex.Female }; var convertResponse = await cClient.AccountConvertAsync(convertInfo); Assert.IsNotNull(convertResponse.AccountId); Assert.IsNotNull(convertResponse.AccountId, convertInfo.AccountId); Assert.AreEqual(convertResponse.AccountName, convertInfo.AccountName); Assert.AreEqual(convertResponse.IdentityNum, convertInfo.IdentityNum); Assert.AreEqual(convertResponse.Name, convertInfo.Name); Assert.AreEqual(convertResponse.PhoneNum, convertInfo.PhoneNum); Assert.AreEqual(convertResponse.Email, convertInfo.Email); Assert.AreEqual(convertResponse.Sex, convertInfo.Sex); }
//------------------------------------------------------------------------- public override void init() { EbLog.Note("ClientSampleApp.init()"); EntityMgr.getDefaultEventPublisher().addHandler(Entity); // EtUCenterSDK示例 var et_ucentersdk = EntityMgr.createEntity <EtUCenterSDK>(null, Entity); var co_ucentersdk = et_ucentersdk.getComponent <ClientUCenterSDK <DefUCenterSDK> >(); co_ucentersdk.UCenterDomain = "http://cragonucenter.chinacloudsites.cn/"; // 注册 AccountRegisterInfo register_request = new AccountRegisterInfo(); register_request.AccountName = "aaaaabbbb"; register_request.Password = "******"; register_request.SuperPassword = "******"; //co_ucentersdk.register(register_request, _onUCenterRegister); // 登录 AccountLoginInfo login_request = new AccountLoginInfo(); login_request.AccountName = "aaaaabbbb"; login_request.Password = "******"; //co_ucentersdk.login(login_request, _onUCenterLogin); // 游客登录 co_ucentersdk.guest(_onUCenterGuestLogin); // 游客帐号转正 AccountConvertInfo convert_info = new AccountConvertInfo(); convert_info.AccountId = "01e94810-ce14-4fff-9c06-16a77990e12c"; convert_info.AccountName = "asdfg"; convert_info.OldPassword = ""; convert_info.Password = ""; convert_info.SuperPassword = ""; convert_info.Sex = Sex.Unknown; convert_info.Name = ""; convert_info.IdentityNum = ""; convert_info.PhoneNum = ""; convert_info.Email = ""; //co_ucentersdk.convert(convert_info, _onUCenterConvert); // 重置密码 AccountResetPasswordInfo resetpassword_request = new AccountResetPasswordInfo(); login_request.AccountName = "aaaaabbbb"; login_request.Password = "******"; //co_ucentersdk.resetPassword(resetpassword_request, _onUCenterResetPassword); // 上传图片 string account_id = "1111"; byte[] buffer = new byte[100]; MemoryStream ms = new MemoryStream(buffer); //co_ucentersdk.uploadProfileImage(account_id, ms, _onUCenterUploadProfileImage); }
public async Task <AccountConvertResponse> AccountConvertAsync(AccountConvertInfo info) { var url = GenerateApiEndpoint("account", "convert"); var response = await httpClient.SendAsyncWithException <AccountConvertInfo, AccountConvertResponse>(HttpMethod.Post, url, info); return(response); }
//------------------------------------------------------------------------- public void convert(AccountConvertInfo request, OnUCenterConvert handler) { if (WWWConvert != null) { return; } ConvertHandler = new Action <UCenterResponseStatus, AccountConvertResponse, UCenterError>(handler); string http_url = _genUrl("convert"); string param = EbTool.jsonSerialize(request); byte[] bytes = Encoding.UTF8.GetBytes(param); Dictionary <string, string> headers = _genHeader(bytes.Length); WWWConvert = new WWW(http_url, bytes, headers); }
//------------------------------------------------------------------------- public override void handleEvent(object sender, EntityEvent e) { if (e is EvUiLoginClickBtnLogin) { // 请求登录 var ev = (EvUiLoginClickBtnLogin)e; if (CoApp.CoUCenter.WWWLogin != null) { //FloatMsgInfo f_info; //f_info.msg = "正在登陆中,请稍候"; //f_info.color = Color.green; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } else { _requestLogin(ev.acc, ev.pwd); } } else if (e is EvUiLoginRegisterAccount) { // 请求注册帐号 var ev = (EvUiLoginRegisterAccount)e; AccountRegisterInfo request = ev.register_acc_data; if (request.Email == null) { request.Email = ""; } if (request.IdentityNum == null) { request.IdentityNum = ""; } if (request.PhoneNum == null) { request.PhoneNum = ""; } if (request.Name == null) { request.Name = ""; } if (request.Password == request.SuperPassword) { //UiHelper.DestroyWaiting(); //FloatMsgInfo f_info; //f_info.msg = "注册失败,密码和超级密码不能相同"; //f_info.color = Color.red; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } else if (CoApp.CoUCenter.WWWRegister != null) { //FloatMsgInfo f_info; //f_info.msg = "正在注册中,请稍候"; //f_info.color = Color.green; //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info); } if (mGuestPlayerInfo == null) { //UiHelper.CreateWaiting(); mPassword = request.Password; CoApp.CoUCenter.register(request, _onUCenterRegister); //todo: 销毁注册界面 UiMgr.Instance.destroyCurrentUi<UiMbCreateAccount>(); } else { AccountConvertInfo guest_convertregisterdata = new AccountConvertInfo(); if (guest_convertregisterdata.IdentityNum == null) { guest_convertregisterdata.IdentityNum = ""; } if (guest_convertregisterdata.PhoneNum == null) { guest_convertregisterdata.PhoneNum = ""; } if (guest_convertregisterdata.Name == null) { guest_convertregisterdata.Name = ""; } guest_convertregisterdata.AccountId = mGuestPlayerInfo.account_id; guest_convertregisterdata.AccountName = request.AccountName; guest_convertregisterdata.Email = request.Email; guest_convertregisterdata.Password = request.Password; guest_convertregisterdata.OldPassword = mGuestPlayerInfo.pwd; guest_convertregisterdata.SuperPassword = request.SuperPassword; guest_convertregisterdata.Sex = request.Sex; //UiHelper.CreateWaiting(); mPassword = request.Password; CoApp.CoUCenter.convert(guest_convertregisterdata, _onUCenterConvert); //todo: 销毁注册界面 UiMgr.Instance.destroyCurrentUi<UiMbCreateAccount>(); } //UiHelper.DestroyWaiting(); } else if (e is EvUiLoginClickBtnFacebook) { // 请求Facebook登录 var ev = (EvUiLoginClickBtnFacebook)e; } else if (e is EvUiLoginClickBtnVisiter) { // 请求游客登录 var ev = (EvUiLoginClickBtnVisiter)e; if (mGuestPlayerInfo == null) { //UiHelper.CreateWaiting(); CoApp.CoUCenter.guest(_uCenterGuestCallBack); } else { _requestLogin(mGuestPlayerInfo.account_name, mGuestPlayerInfo.pwd); } } else if (e is EvUiRequestGetPwd) { // 请求获取忘记密码 var ev = (EvUiRequestGetPwd)e; string super_pwd = ev.super_pwd; } else if (e is EvUiLoginDeleteGuest) { //清除游客 _clearGuest(); } }