// //登陆按钮 // void OnClickLoginButton() { var userName = Username_L.text; var pwd = Password_L.text; AVUser.LogInAsync(userName, pwd).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { MainThreadDispatcher.Send(_ => { var error = t.Exception.Message; // 登录失败,可以查看错误信息。 InfText.text = error; Inf.SetActive(true); }, null); } else { MainThreadDispatcher.Send(_ => { //登录成功 InfText.text = "登陆成功!"; Inf.SetActive(true); }, null); } }); LoginPanel.SetActive(false); Username_L.text = ""; Password_L.text = ""; _nowUser = AVUser.CurrentUser; _nowUsername = _nowUser.Username; Users.text = "当前用户:" + _nowUsername; }
public void Login() { var userName = UserName.text; var pwd = Password.text; AVUser.LogInAsync(userName, pwd).ContinueWith(t => { MainThreadDispatcher.Post(_ => { if (t.IsFaulted || t.IsCanceled) { var error = t.Exception.Message; // 登录失败,可以查看错误信息。 Debug.Log(error); ErrorText.text = error; } else { //登录成功 Debug.Log("登陆成功"); UserInfo.User = t.Result; // 加入realtime NetworkService.Instance.JoinLobby(); // 跳转到大厅界面 gameObject.SetActive(false); LobbyPanel.SetActive(true); } }, null); }); }
void OnGUI() { if (GUILayout.Button("创建一个士兵")) { AVUser.LogInAsync("games", "123").ContinueWith(loginTask => { Debug.Log("login success!"); user = (AVUser)loginTask.Result; AVUser otherUser = null; AVUser.Query.GetAsync("55220263e4b07952a95fbf7a").ContinueWith(t => { otherUser = (AVUser)t.Result; AVObject soldier = new AVObject("Soldier") { { "type", 3 }, { "lv", 1 }, { "exp", 50 }, { "user2", new List <AVUser>() { user, otherUser } } }; soldier.SaveAsync().ContinueWith(saveTask => { Debug.Log("solider created!"); }); }); }); } }
public async Task <AVUser> LogIn(string username, string password, TMContext context) { Console.WriteLine($"username:{username}, password:{password}"); var user = await AVUser.LogInAsync(username, password); context.Client.User = user; return(user); }
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)); } }
private async void Button_Click(object sender, RoutedEventArgs e) { ///AVSession.SelfId 是标识 当前AVSession 的 PeerId,是跟Server 交互的唯一可靠的 ID, ///请开发者放心,这个Id 在不同应用之间是不会产生混淆的,你可以叫大卫,别的开发者也可以在他的 LeanCloud 的应用叫做大卫,而服务端会做区分。 ///这里直接用名字作为 PeerId 是为了方便演示,出去了将PeerId 转化为 Display Name 的繁琐,但是实际运用的时候还是建议使用唯一性最好的GUID或者直接使用AVUser.objectId更为妥当。 try { var user = await AVUser.LogInAsync(txb_selfId.Text.Trim(), txb_pwd.Password.Trim()); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)); NavigationService.RemoveBackEntry(); } catch { } }
// Update is called once per frame void Update() { var userName = "******"; var pwd = "888888"; AVUser.LogInAsync(userName, pwd).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { var error = t.Exception.Message; // 登录失败,可以查看错误信息。 } else { //登录成功 } }); }
public void DoLogin(string userName, string passWord, Action action) { AVUser.LogInAsync(userName, passWord).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { var error = t.Exception.Message; } else { IsLogin = true; if (action != null) { action(); } } }); }
private async void ConnectExecuteAsync(object parameter) { var passwordBox = parameter as PasswordBox; Connecting = true; var password = passwordBox.Password; var user = await AVUser.LogInAsync(this.ClienId, password); this.ButtonText = "欢迎回来, " + user.Username; var teamVM = ServiceLocator.Current.GetInstance <TeamViewModel>(); await teamVM.InitByUserAsync(user); client = await realtime.CreateClient(ClienId, tag : Tag, deviceId : DeviceId); client.OnOfflineMessageReceived += Client_OnOfflineMessageReceived; Connecting = false; Connected = true; }
public Task TestLogIn() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "sessionToken", "llaKcolnu" }, { "username", "ihave" }, { "password", "adream" } } }; IObjectState newState = new MutableObjectState { ObjectId = "some0neTol4v4" }; var mockController = new Mock <IAVUserController>(); mockController.Setup(obj => obj.LogInAsync("ihave", "adream", It.IsAny <CancellationToken>())).Returns(Task.FromResult(newState)); AVPlugins.Instance = new AVPlugins { UserController = mockController.Object }; AVObject.RegisterSubclass <AVUser>(); AVObject.RegisterSubclass <AVSession>(); return(AVUser.LogInAsync("ihave", "adream").ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); mockController.Verify(obj => obj.LogInAsync("ihave", "adream", It.IsAny <CancellationToken>()), Times.Exactly(1)); var user = t.Result; Assert.False(user.IsDirty); Assert.Null(user.Username); Assert.AreEqual("some0neTol4v4", user.ObjectId); })); }
private async void SaveUser() { var studentInfo = await app.Assist.GetStudentDetails(); var user = AVObject.Create <AVUser>(); // 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 => { }); }); }
private void OnClickLoginBtn() { var userName = UserNameInputField.text; var pwd = PasswordInputField.text; AVUser.LogInAsync(userName, pwd).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { var error = t.Exception.Message; // 登录失败,可以查看错误信息。 GlobalThread.runOnMainThread(() => { PanelManager.FloatPanel.Show("登录失败,请联系管理员!"); }); } else { GlobalThread.runOnMainThread(() => { PanelManager.FloatPanel.Show("登录成功!" + AVUser.CurrentUser.ObjectId); SceneManager.LoadScene("Scenes/" + GameScene.LoadingScene); }); } }); }
static async public Task <AVUser> SingIn(string userName, string password) { 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(); } AVUser user = await AVUser.LogInAsync(userName, password); return(user); } catch (AVException ex) { throw ex; } }
public void Login(string userName, string passWord) //登陆检测 { isLoginOK = false; AVUser.LogInAsync(userName, passWord).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { var error = t.Exception.Message; // 登录失败,可以查看错误信息。 isLoginOK = false; } else { var user = t.Result; isLoginOK = true; UserName = userName; UserID = user.ObjectId; Debug.Log("登陆成功"); Debug.Log("用户ID1" + UserID); thisuser = AVUser.CurrentUser; Debug.Log("用户ID2" + thisuser.ObjectId); } }); }
private static void LoginLC(string username, string password, Action successAction, Action <string> failedAction) { Debug.Log(username); Debug.Log(password); AVUser.LogInAsync(username, password).ContinueWith(t => { if (!t.IsFaulted && !t.IsCanceled) { if (successAction != null) { successAction(); } Debug.Log("Login Success"); } else { if (failedAction != null) { failedAction(t.Exception.Message); } Debug.Log("Login Failed"); } }); }
/// <summary> /// 登录 /// </summary> /// <param name="userName">用户名</param> /// <param name="password">密码</param> /// <returns></returns> private Task Login(string userName, string password) { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { _loginErrorText.text = "账号或密码不能为空"; return(Task.FromResult(0)); } //存在该用户,进行登录 return(AVUser.LogInAsync(_accountInput.text, _passwordInput.text).ContinueToForeground(p => { if (p.IsFaulted) { //TODO return UnityTask.FromException(p.Exception); } PlayerPrefs.SetString(_theLastLoginUser, _accountInput.text); PlayerPrefs.SetInt(_isRememberPassword, _rememberPasswordToggle.isOn ? 1 : 0); Debug.Log("登录成功!"); return UnityTask.FromResult(0); }).AsBackground()); }
public void SendLoginMsgCS(string userName, string passWord) { if (MainSystem.Instance.isOpenNetWork) { Debug.Log("NetWork Send " + userName + " " + passWord); AVUser.LogInAsync(userName, passWord).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { Debug.Log("NetWork Send failed"); _isLoginFailedCall = true; } else { Debug.Log("NetWork Send 1111登陆成功"); _isLoginSuccessCall = true; } }); } else { _isLoginSuccessCall = true; } }
private void btn_login_Click(object sender, EventArgs e) { AVUser.LogInAsync(txb_username.Text.Trim(), txb_password.Text.Trim()); }