public Task<ParseUser> GetAsync(CancellationToken cancellationToken) { ParseUser cachedCurrent; lock (mutex) { cachedCurrent = CurrentUser; } if (cachedCurrent != null) { return Task<ParseUser>.FromResult(cachedCurrent); } return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(t => { object temp; ParseClient.ApplicationSettings.TryGetValue("CurrentUser", out temp); var userDataString = temp as string; ParseUser user = null; if (userDataString != null) { var userData = Json.Parse(userDataString) as IDictionary<string, object>; user = ParseObject.CreateWithoutData<ParseUser>(null); user.HandleFetchResult(ParseObjectCoder.Instance.Decode(userData, ParseDecoder.Instance)); } CurrentUser = user; return user; }); }, cancellationToken); }
public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { Task saveTask = null; if (user == null) { saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.RemoveAsync("CurrentUser")) .Unwrap(); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); } saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.AddAsync("CurrentUser", Json.Encode(data))) .Unwrap(); } CurrentUser = user; return saveTask; }).Unwrap(); }, cancellationToken); }
public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { if (user == null) { ParseClient.ApplicationSettings.Remove("CurrentUser"); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatString); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatString); } ParseClient.ApplicationSettings["CurrentUser"] = Json.Encode(data); } CurrentUser = user; }); }, cancellationToken); }
public UserViewModel(ParseUser user) { _user = user; var task = LoadData(); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { ParseUser.LogOut(); VisualStateManager.GoToState(this, "LoginState", true); }
void LogoutButton_Click(dfControl control, dfMouseEventArgs mouseEvent) { LogoutScript.Logout(); ParseUser.LogOut(); Application.LoadLevel("DFGUI Login"); }
public void Logout() { ParseUser.LogOut(); var currentUser = ParseUser.CurrentUser; //This is null }
public void Remove(ParseUser member) { _members.Remove(member); }
/// the create account touch up inside button action lives here /// Notice how I added "async" as a prefix to the default event definition /// We will discuss async/await later, all Parse calls must use the Async/Await pattern async partial void BtnCreateAccount_TouchUpInside(UIButton sender) { var firstName = txtFirstName.Text; var lastName = txtLastName.Text; var email = txtEmail.Text; var password = txtPassword.Text; var confirmPassword = txtConfirmpassword.Text; var alert = new UIAlertView(); if ((string.IsNullOrEmpty(email)) || (string.IsNullOrEmpty(password)) || (string.IsNullOrEmpty(firstName)) || (string.IsNullOrEmpty(lastName))) { // display an alert pop-up if any of the required fields are left out alert = new UIAlertView("Input Validation Failed", "Please complete all the input fields!", null, "OK"); alert.Show(); } else { if (password != confirmPassword) { // display an alert pop-up if password is not the same as confirm password alert = new UIAlertView("Input Validation Failed", "Password and Confirm Password must match!", null, "OK"); alert.Show(); } else { // call Parse to create a new user, put it in a try-catch block // if an internet connection doesn’t exist, the Parse call will fail // in addition, if the email already exists in Parse, the call will fail try { // create a new user in Parse, // by setting the default User class properties as follows: var user = new ParseUser() { Username = email, Password = password, Email = email }; // the non-default fields can be set using the following approach user["LastName"] = lastName; user["FirstName"] = firstName; // make an asynchronous call to Parse to create a new user await user.SignUpAsync(); // show an alert to confirm alert = new UIAlertView("Account Created", "Your account has been successfully created!", null, "OK"); alert.Show(); // navigate to the login page now that the user is registered NavigationController.PopViewController(true); } catch (Exception ex) { var error = ex.Message; alert = new UIAlertView("Registration Failed", "Sorry, we might be experiencing some connectivity difficulties or your email is already in the system!", null, "OK"); alert.Show(); } } } }
public Task<ParseUser> GetAsync(CancellationToken cancellationToken) { ParseUser cachedCurrent; lock (mutex) { cachedCurrent = CurrentUser; } if (cachedCurrent != null) { return Task<ParseUser>.FromResult(cachedCurrent); } return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { return storageController.LoadAsync().OnSuccess(t => { object temp; t.Result.TryGetValue("CurrentUser", out temp); var userDataString = temp as string; ParseUser user = null; if (userDataString != null) { var userData = Json.Parse(userDataString) as IDictionary<string, object>; var state = ParseObjectCoder.Instance.Decode(userData, ParseDecoder.Instance); user = ParseObject.FromState<ParseUser>(state, "_User"); } CurrentUser = user; return user; }); }).Unwrap(); }, cancellationToken); }
public static IDictionary <string, IDictionary <string, object> > GetAuthData(this ParseUser user) { return(user.AuthData); }
private async void register(object sender, RoutedEventArgs e) { string name_c = name.Text; string mail = email.Text; string fecha = Fecha_Nacimiento.Date.Day + "/" + Fecha_Nacimiento.Date.Month + "/" + Fecha_Nacimiento.Date.Year; int s = sex.SelectedIndex; string sexo = ""; switch (s) { case 0: sexo = "Hombre"; break; case 1: sexo = "Mujer"; break; } string userr = user.Text; string passs = pass.Password; string re_passs = re_pass.Password; int cont_error = 0; if (name_c.Equals("") || userr.Equals("") || passs.Equals("") || re_passs.Equals("") || mail.Equals("")) { Errors.Text = "Por favor llene todos los campos."; Errors.Visibility = Visibility.Visible; var margin = panel.Margin; margin.Top = -17; panel.Margin = margin; cont_error = 1; } if (!passs.Equals(re_passs)) { Errors.Text = "Las contraseñas deben conicidir."; Errors.Visibility = Visibility.Visible; var margin = panel.Margin; margin.Top = -17; panel.Margin = margin; cont_error = 1; } if (cont_error == 0) { try { PrgRing.Visibility = Visibility.Visible; panel.Visibility = Visibility.Collapsed; if (photo == null) { var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation; var assetsFolder = await packageLocation.GetFolderAsync("Assets"); if (sexo.Equals("Mujer")) { photo = await assetsFolder.GetFileAsync("mujer.jpg"); } else { photo = await assetsFolder.GetFileAsync("hombre.jpg"); } } var bytes = await GetBtyeFromFile(photo); ParseFile parseFile = new ParseFile(userr + ".jpg", bytes, "image/jpeg"); ParseUser user = new ParseUser() { Username = userr, Password = passs, Email = mail }; // other fields can be set just like with ParseObject user["name"] = name_c; user["sex"] = sexo; user["b_date"] = fecha; user.Add("photo", null); await user.SignUpAsync(); PrgRing.Visibility = Visibility.Collapsed; user["photo"] = parseFile; await user.SaveAsync(); await ParseUser.LogInAsync(userr, passs); Accept.Visibility = Visibility.Visible; await Task.Delay(2000); Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(MainPage)); } catch (Exception ex) { PrgRing.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Visible; string error = ex.Message; if (error.Contains("username")) { Errors.Text = "El usuario " + userr + " ya se encuentra registrado."; Errors.Visibility = Visibility.Visible; var margin = panel.Margin; margin.Top = -17; panel.Margin = margin; cont_error = 1; } if (error.Contains("email")) { Errors.Text = "El correo electrónico " + mail + " ya se encuentra registrado."; Errors.Visibility = Visibility.Visible; var margin = panel.Margin; margin.Top = -17; panel.Margin = margin; cont_error = 1; } } } }
public void SignOutUsingParse() { ParseUser.LogOut(); }
public void ClearFromMemory() { CurrentUser = null; }
public bool IsCurrent(ParseUser user) { lock (mutex) { return CurrentUser == user; } }
public void LogOutAsync() { ParseUser.LogOut(); }
public static Task UnlinkFromAsync(this ParseUser user, string authType, CancellationToken cancellationToken) { return(user.UnlinkFromAsync(authType, cancellationToken)); }
public async void Init() { TestingHelpers.InitParse(); ParseUser.LogOut(); }
public static Task <ParseUser> LogInWithAsync(string authType, CancellationToken cancellationToken) { return(ParseUser.LogInWithAsync(authType, cancellationToken)); }
public PaymentViewModel(ParseUser user) { _user = user; }
public static Task <ParseUser> LogInWithAsync(string authType, IDictionary <string, object> data, CancellationToken cancellationToken) { return(ParseUser.LogInWithAsync(authType, data, cancellationToken)); }
async partial void BtnLogin_TouchUpInside(UIButton sender) { // to prevent the user from clicking on the button multiple times, // I will hide my login button when it is clicked on till all the processing is complete btnLogin.Hidden = true; var email = txtEmail.Text; var password = txtPassword.Text; var error = "Enter a valid E-mail Address and Password"; var alert = new UIAlertView(); // if email and password is not provided don't make the Parse call if ((string.IsNullOrEmpty(email)) || (string.IsNullOrEmpty(password))) { alert = new UIAlertView("Login Failed", error, null, "OK"); alert.Show(); txtEmail.Text = ""; txtPassword.Text = ""; } else { try { // you only need this one line to authenticate the user against Parse ParseUser myUser = await ParseUser.LogInAsync(email, password); // navigate to the welcome page, // note: "home" is the StoryBoard ID of the HomeController var vendStatus = myUser["Vendor"]; Boolean bVendor = (Boolean)vendStatus; if (bVendor == true) { var vend = Storyboard.InstantiateViewController("VendorTab") as VendorTabController; NavigationController.PushViewController(vend, true); } else { var home = Storyboard.InstantiateViewController("Tab") as TabController; NavigationController.PushViewController(home, true); } //var home = Storyboard.InstantiateViewController("Tab") as TabController; //NavigationController.PushViewController(home, true); } catch (ParseException f) { alert = new UIAlertView("Login Failed", error, null, "OK"); alert.Show(); } catch (Exception f) { alert = new UIAlertView("Login Failed", "Check your network access! Or try again later", null, "OK"); alert.Show(); } } // now I will display my login button btnLogin.Hidden = false; }
public static Task LinkWithAsync(this ParseUser user, string authType, CancellationToken cancellationToken) { return(user.LinkWithAsync(authType, cancellationToken)); }
// Update is called once per frame void Update() { if (bufferedLog.Count > 0) { while (bufferedLog.Count > 0) { AddLog(bufferedLog.Pop()); } } if (objectsToEnable.Count > 0) { while (objectsToEnable.Count > 0) { GameObject objectToEnable = objectsToEnable.Pop(); if (objectToEnable.GetComponent <LoginPanel>() != null) { refreshLoginPanel(); } else if (objectToEnable.GetComponent <Button>() != null) { objectToEnable.GetComponent <Button>().interactable = true; } } } if (globalLeaderboardUsers != null) { string tempResult = "updated " + DateTime.Now.ToString() + "\n"; int position = 1; foreach (ParseUser user in globalLeaderboardUsers) { int score = 0; if (user.ContainsKey("highscore")) { score = user.Get <int>("highscore"); } tempResult = tempResult + position + ". " + user.Username.Substring(0, Mathf.Min(user.Username.Length, 10)) + " | " + score + "\n"; position++; } leaderboard.StoreResult(true, tempResult); leaderboard.UpdateResult(true); globalLeaderboardUsers = null; resetLeaderboardMode(); } if (friendsLeaderboardUsers != null) { string tempResult = "updated " + DateTime.Now.ToString() + "\n"; int position = 1; int playerScore = 0; ParseUser currentUser = ParseUser.CurrentUser; if (currentUser.ContainsKey("highscore")) { playerScore = currentUser.Get <int>("highscore"); } bool playerAdded = false; foreach (ParseUser user in friendsLeaderboardUsers) { int score = 0; if (user.ContainsKey("highscore")) { score = user.Get <int>("highscore"); } if (!playerAdded) { if (score <= playerScore) { tempResult = tempResult + position + "." + currentUser.Username.Substring(0, Mathf.Min(currentUser.Username.Length, 10)) + " | " + playerScore + "\n"; position++; playerAdded = true; } } tempResult = tempResult + position + ". " + user.Username.Substring(0, Mathf.Min(user.Username.Length, 10)) + " | " + score + "\n"; position++; } if (!playerAdded) { tempResult = tempResult + position + "." + currentUser.Username.Substring(0, Mathf.Min(currentUser.Username.Length, 10)) + " | " + playerScore + "\n"; position++; playerAdded = true; } leaderboard.StoreResult(false, tempResult); friendsLeaderboardUsers = null; } if (parseUserUpdatePending) { StartUpdate(); parseUserUpdatePending = false; } }
public static Task LinkWithAsync(this ParseUser user, string authType, IDictionary <string, object> data, CancellationToken cancellationToken) { return(user.LinkWithAsync(authType, data, cancellationToken)); }
// Instantiate building blocks using varible "result" // It is up to the caller to check so that result is valid IEnumerator InstantiateBlocks() { // Safety check! if (result != null) { Time.timeScale = 30f; // Check whos turn it is ParseUser playerTurn = AppModel.currentMatch["playerTurn"] as ParseUser; bool myTurn = false; if (!playerTurn.ObjectId.Equals(ParseUser.CurrentUser.ObjectId)) { headerText.text = "Waiting for " + AppModel.currentOpponent["displayName"].ToString(); refreshImage.gameObject.SetActive(true); refreshImage.transform.parent.gameObject.SetActive(true); } else { headerText.text = "Your turn against " + AppModel.currentOpponent["displayName"].ToString(); refreshImage.gameObject.SetActive(false); refreshImage.transform.parent.gameObject.SetActive(false); myTurn = true; } List <GameObject> newBuildingBlocksList = new List <GameObject>(); foreach (var item in result) { //Instantiate block from prefab ParseBuildingBlock pb = item as ParseBuildingBlock; Quaternion rotation = Quaternion.identity; Vector3 eulerAngles = rotation.eulerAngles; eulerAngles.z = pb.originalRotZ; rotation.eulerAngles = eulerAngles; GameObject newBuildingBlock = Instantiate(buildingBlocks[(int)pb.GetBuildingBlockType()], new Vector3(pb.originalPosX, pb.originalPosY, -1f), rotation) as GameObject; //Store Parse Object ID in prefab class BuildingBlock newBuildingBlockScript = newBuildingBlock.GetComponentInChildren <BuildingBlock>(); newBuildingBlockScript.objectId = pb.ObjectId; // Set building block to released (not swinging) newBuildingBlockScript.isHeldAtStart = false; newBuildingBlocksList.Add(newBuildingBlockScript.gameObject); nextBuildingBlockIndex++; // Add to next building block index so that we know the index for the next building block we place in the scene yield return(new WaitForSeconds(.01f)); int ctr = 0, listLength = newBuildingBlocksList.Count; while (ctr < listLength) { while (!MathUtilities.IsApproximately(newBuildingBlocksList[ctr].GetComponent <Rigidbody2D>().velocity.x, 0.0f) || !MathUtilities.IsApproximately(newBuildingBlocksList[ctr].GetComponent <Rigidbody2D>().velocity.y, 0.0f) || !MathUtilities.IsApproximately(newBuildingBlocksList[ctr].GetComponent <Rigidbody2D>().angularVelocity, 0.0f)) { // Break from coroutine and reset ctr in order to start over looping all the building blocks yield return(null); ctr = 0; continue; } ctr++; } } Time.timeScale = 1f; if (myTurn) { buildingBlockSlotMachine.GenerateNewBuildingBlocks(); } } }
public static Task UpgradeToRevocableSessionAsync(this ParseUser user, CancellationToken cancellationToken) { return(user.UpgradeToRevocableSessionAsync(cancellationToken)); }
public bool IsOwner(ParseUser user) { return(User.ObjectId == user.ObjectId); }
public string GetCurrentUserId() { ParseUser currentUser = ParseUser.CurrentUser; return(currentUser.ObjectId); }
public async void passwordReset(string email) { ParseUser.RequestPasswordResetAsync(email); }
public void Logout() { ParseUser.LogOut(); }
private void OnLogOutButtonClick(object sender, RoutedEventArgs e) { ParseUser.LogOut(); (Window.Current.Content as Frame).Navigate(typeof(LogInPage)); }
private static void LogoutP() { ParseUser.LogOut(); }
public override void OnEnter() { _task = ParseUser.RequestPasswordResetAsync(email.Value); }
static public void LoginWithUser(ParseUser user) { Application.LoadLevel("MyMatches"); }