public void Singup(string userName, string passWord) { isSignupOK = false; var user = new AVUser(); user.Username = userName; user.Password = passWord; user.SignUpAsync().ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { isSignupOK = false; Debug.Log("注册失败"); } else { string uid = user.ObjectId; thisuser = AVUser.CurrentUser; UserName = userName; UserID = thisuser.ObjectId; isSignupOK = true; makePlayerData(UserID); Debug.Log("登陆成功userID=" + UserID); } }); }
public Task TestRequestRealtimeSignature() { AVClient.HttpLog(Console.WriteLine); var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); return AVCloud.RequestRealtimeSignatureAsync(); }).Unwrap().ContinueWith((Task <AVCloud.RealtimeSignature> t) => { Assert.IsFalse(t.IsCanceled); Assert.IsFalse(t.IsFaulted); Assert.IsNotEmpty(t.Result.ClientId); Assert.AreNotEqual(t.Result.Timestamp, 0); Assert.IsNotEmpty(t.Result.Signature); Assert.IsNotEmpty(t.Result.Nonce); })); }
async private void CreateUser() { string uri = "https://api.leancloud.cn/1.1/classes/Friend"; string requestString = ""; for (int i = 0; i < 60; i++) { var user = new AVUser(); user.Username = string.Format("TestUser{0}", i); user.Password = "******"; user.Email = string.Format("user{0}@126.com", i); await user.SignUpAsync(); foreach (var u in OurUserList) { WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/json"); client.Headers.Add("X-AVOSCloud-Application-Id", "u2usgtzl5t8w9t2qpf8bbc88rvg85g5tgjtja3jpq0gfoilc"); client.Headers.Add("X-AVOSCloud-Application-Key", "dspdy8ip356aahviafq216hszwb0gp908vov9b4cck7nrywu"); requestString = string.Format(jsonString, u, user.ObjectId); requestString = requestString.Replace('[', '{').Replace(']', '}'); client.UploadString(uri, requestString); } } }
public Task TestRefreshSessionToken() { string originSessionToken = ""; var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); originSessionToken = user.SessionToken; return user.RefreshSessionTokenAsync(CancellationToken.None); }).Unwrap().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); Assert.AreNotEqual(originSessionToken, user.SessionToken); })); }
// Update is called once per frame public void SignUp() { var userName = UserName.text; var pwd = Password.text; var email = Email.text; var user = new AVUser(); user.Username = userName; user.Password = pwd; user.Email = email; SignUpButton.interactable = false; user.SignUpAsync().ContinueWith(t => { MainThreadDispatcher.Send(_ => { SignUpButton.interactable = true; var uid = user.ObjectId; if (t.IsFaulted) { Debug.Log(t.Exception.InnerExceptions[0].Message); ErrorText.text = t.Exception.InnerExceptions[0].Message; return; } Debug.Log(uid); UserInfo.User = user; }, null); }); }
public Task TestFollowUser() { var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { var query = new AVQuery <AVUser>(); return query.FirstAsync(); }).Unwrap().ContinueWith(s => { var friend = s.Result; return user.FollowAsync(friend.ObjectId); }).Unwrap().ContinueWith(x => { var rtn = x.Result; Assert.IsTrue(rtn); return Task.FromResult(0); })); }
public void SendRegsiterMsgCS(string userName, string passWord) { if (MainSystem.Instance.isOpenNetWork) { if (userName != null && passWord != null) { var user = new AVUser(); user.Username = userName; user.Password = passWord; user.SignUpAsync().ContinueWith(t => { if (!t.IsFaulted) { Debug.Log("NetWork SendRegsiterMsgCS 注册成功"); var uid = user.ObjectId; _isRegisterSuccessCall = true; } else { Debug.Log("NetWork SendRegsiterMsgCS 注册失败"); _isRegisterFailedCall = true; } }); } else { _isRegisterFailedCall = true; } } else { _isRegisterSuccessCall = true; } }
static public async Task <AVUser> SignUp(string userName, string password, string email) { try { using (var md5 = MD5.Create()) { var data = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); var sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } password = sBuilder.ToString(); } var user = new AVUser() { Username = userName, Password = password, Email = email, }; await user.SignUpAsync(); return(user); }catch (AVException ex) { throw ex; } }
private void OnClickSendRegisterCodeBtn() { var user = new AVUser(); user.Username = UserNameInputField.text; user.Password = PasswordInputField.text; user.MobilePhoneNumber = PhoneNumberRegisterInputField.text; var task = user.SignUpAsync(); }
private void LoginOrSignin() { if (AVUser.CurrentUser == null) { AVUser user = new AVUser(); user.Username = "******"; user.Password = "******"; user.Email = "*****@*****.**"; user.SignUpAsync(); } }
public void DoRegist(string userName, string password, string email) { AVUser user = new AVUser(); user.Username = userName; user.Password = password; user.Email = email; user.SignUpAsync().ContinueWith(t => { UID = user.ObjectId; // 创建玩家的Village VillageData.DB_CreateVillage(); }); }
private async void btn_stepIn_Click(object sender, RoutedEventArgs e) { if (txb_password.Text.Trim() == txb_password_verify.Text.Trim()) { AVUser user = new AVUser() { Username = txb_username.Text.Trim(), Password = txb_password.Text.Trim() }; await user.SignUpAsync(); await AVUser.LogInAsync(txb_username.Text.Trim(), txb_password.Text.Trim()); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)); } }
// Update is called once per frame void Update() { var userName = "******"; var pwd = "888888"; var email = "*****@*****.**"; var user = new AVUser(); user.Username = userName; user.Password = pwd; user.Email = email; user.SignUpAsync().ContinueWith(t => { var uid = user.ObjectId; }); }
public static Task <AVUser> SignUp(string pwd) { var u = Utils.RandomUsername(); AVUser user = new AVUser() { Username = u, Password = pwd, MobilePhoneNumber = GetRandomTel() }; return(user.SignUpAsync().ContinueWith(t => { return user; })); }
/// <summary> /// 点击确认注册按钮 /// </summary> private void OnRegisterConfirmBtnClick() { if (string.IsNullOrEmpty(_accountInput.text) || string.IsNullOrEmpty(_passwordInput.text)) { _registerErrorText.text = "账号或密码不能为空!"; return; } //是否存在该用户 AVUser.Query.WhereEqualTo(_netComponent.GetProperty <AVUser>(t => t.Username), _accountInput.text) .CountAsync().ContinueWith(t => { if (t.Result != 0) { _registerErrorText.text = "该账号已注册!"; return; } //不存在该用户,可以注册 var user = new AVUser() { Username = _accountInput.text, Password = _passwordInput.text, [_showPasswordKey] = _passwordInput.text }; user.SignUpAsync().ContinueToForeground(p => { string petName = new RandomComponent().RandomChinese(UnityEngine.Random.Range(2, 5)); var player = new Player { PetName = petName, UserId = AVUser.CurrentUser }; player.SaveAsync().ContinueWith(n => { Login(_accountInput.text, _passwordInput.text).ContinueToForeground(a => { _uiComponent.SyncOpenView <MainView>(); _uiComponent.DestroyView <LoginView>(); }); } ); }); }); }
public Task TestSignUpWithInvalidServerData() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "sessionToken", "llaKcolnu" } } }; AVUser user = AVObjectExtensions.FromState <AVUser>(state, "_User"); return(user.SignUpAsync().ContinueWith(t => { Assert.True(t.IsFaulted); Assert.IsInstanceOf <InvalidOperationException>(t.Exception.InnerException); })); }
//注册按钮 private async void Btnregister_Click(object sender, RoutedEventArgs e) { if (UsernameHasWarning) { Username_LostFocus(new object(), new RoutedEventArgs()); } else if (PasswordHasWarning) { Password_LostFocus(new object(), new RoutedEventArgs()); } else if (EmailHasWarning) { Email_LostFocus(new object(), new RoutedEventArgs()); } else if (PhoneHasWarning) { Phone_LostFocus(new object(), new RoutedEventArgs()); } else { var user = new AVUser { Username = username.Text, Password = password.Text, Email = email.Text, MobilePhoneNumber = phone.Text }; try { await user.SignUpAsync(); App.Current.Dispatcher.Invoke((Action)(() => { MessageBox.Show("注册成功"); })); Login login = new Login(email.Text, password.Text); login.Show(); this.Close(); } catch (Exception error) { MessageBox.Show(error.Message); } } }
private void RegisterUser() { var user = new AVUser(); user.Username = "******"; user.Password = "******"; user.Email = "*****@*****.**"; user.SignUpAsync().ContinueWith(t => { if (t.IsFaulted) { Debug.Log("Register Failed"); } else { Debug.Log("Register Succeeded"); } }); }
public Task TestSignUp() { var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); Assert.AreEqual(u, user.Username); Assert.False(user.GetState().ContainsKey("password")); Assert.IsNotNull(user.ObjectId); })); }
public void Singup() { var user = new AVUser(); user.Username = SystemInfo.deviceUniqueIdentifier; //唯一识别码 user.Password = SystemInfo.deviceUniqueIdentifier.Substring(2, 14); user["testA"] = "aaa"; user.SignUpAsync().ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { Debug.Log(t.Exception.Message); } else { Debug.Log(t.Exception.Message); string uid = user.ObjectId; } }); }
public Task TestUpdatePassword() { var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); return user.UpdatePassword(p, Utils.RandomString(10), CancellationToken.None); }).ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); })); }
private async void SaveUser() { var studentInfo = await app.Assist.GetStudentDetails(); var user = new AVUser(); var username = app.Assist.Username; var password = studentInfo.Id + studentInfo.GaokaoId; user.Username = username; user.Password = password; user.Email = user.Username + "@mail.bnu.edu.cn"; user["RegistrationTime"] = studentInfo.RegistrationTime; user["Nationality"] = studentInfo.Nationality; user["AdmitSpeciality"] = studentInfo.Speciality; user["MiddleSchool"] = studentInfo.MiddleSchool; user["ClassName"] = studentInfo.ClassName; user["CollegeWill"] = studentInfo.CollegeWill; user["SchoolSystem"] = studentInfo.SchoolSystem; user["EducationLevel"] = studentInfo.EducationLevel; user["Name"] = studentInfo.Name; user["Number"] = studentInfo.Number; user["College"] = studentInfo.College; user["Gender"] = studentInfo.Gender; user["Address"] = studentInfo.Address; user["Pinyin"] = studentInfo.Pinyin; user["mobile"] = studentInfo.Mobile; user["RegistrationGrade"] = studentInfo.RegistrationGrade; user["Birthday"] = studentInfo.Birthday; await user.SignUpAsync().ContinueWith(async t => { await AVUser.LogInAsync(username, password).ContinueWith(t2 => { }); }); }
// //注册按钮 // void OnClickRegisterButton() { var userName = Username_R.text; var pwd = Password_R.text; var pwd2 = Password2_R.text; var user = new AVUser(); user.Username = userName; user.Password = pwd; user.SignUpAsync().ContinueWith(t => { var uid = user.ObjectId; MainThreadDispatcher.Send(_ => { InfText.text = "注册成功!"; Inf.SetActive(true); }, null); }); RegisterPanel.SetActive(false); Username_R.text = ""; Password_R.text = ""; Password2_R.text = ""; }
public Task TestIsAuthenticatedAsync() { var u = Utils.RandomUsername(); var p = Utils.RandomString(10); AVUser user = new AVUser() { Username = u, Password = p }; return(user.SignUpAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); return user.IsAuthenticatedAsync(); }).Unwrap().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); Assert.True(t.Result); })); }