public void updateUserProfile(Firebase.Auth.FirebaseUser user, string name, string photoUrl) { if (!photoUrl.Contains("http")) { Debug.Log("Profile Picture is not an http(s) link"); return; } if (user != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = name, PhotoUrl = new System.Uri(photoUrl), }; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } Debug.Log("User profile updated successfully."); }); } }
static void UpdateProfile(string proposedName, Status status, Action <CharacterSettings> callBack, Action <string> errorCallBack) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = proposedName, //May be used for OOC chat, so find way to detect imposters PhotoUrl = null //TODO: set up later (user will eventually be able to update profile photo via the website) }; Instance.auth.CurrentUser.UpdateUserProfileAsync(profile).ContinueWith(profileTask => { if (profileTask.IsFaulted) { //The account will need to be removed from Auth records by an admin so user can try again: //(maybe their internet dropped right at the moment of profile setting). //Display name is critical so it needs to be set here and //account owners cannot destroy their own accounts. errorCallBack.Invoke("Major Error!: Please contact the dev team to help resolve it. " + profileTask.Exception.Message); Instance.isFirstTime = false; return; } Logger.LogFormat($"Firebase user created successfully: {Instance.auth.CurrentUser.DisplayName}", Category.DatabaseAPI); }); }
public void updateProfile() { var name = TopManager.UI.Name.text; if (name == null) { name = "no name"; } var profile = new Firebase.Auth.UserProfile { DisplayName = name }; //var user = GameData.Auth.CurrentUser; var user = GameData.User; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } Debug.Log("User profile updated successfully."); }); TopManager.Created = true; }
public override void Resume(StateExitValue results) { ShowUI(); if (results != null) { if (results.sourceState == typeof(WaitForTask)) { WaitForTask.Results taskResults = results.data as WaitForTask.Results; if (taskResults.task.IsFaulted) { manager.PushState(new BasicDialog("Could not create account.")); } else { if (!string.IsNullOrEmpty(dialogComponent.DisplayName.text)) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile(); profile.DisplayName = dialogComponent.DisplayName.text; // We are fine with this happening in the background, // so just return to the previous state after triggering the update. auth.CurrentUser.UpdateUserProfileAsync(profile); } manager.PopState(); } } } }
void AdditionalOperations() { Firebase.Auth.FirebaseUser user = auth.CurrentUser; if (user != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = UserDisplayInputField.text, //PhotoUrl = new System.Uri("https://example.com/jane-q-user/profile.jpg"), }; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } Debug.Log("User profile updated successfully."); }); } }
void SetProfileAsCollaborate(Firebase.Auth.FirebaseUser _user, string usernameStr, string mailStr, string pwdStr) { if (_user != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = usernameStr, }; _user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } Debug.Log("User Profile update successfully."); UserSignIn(mailStr, pwdStr); }); } }
protected async override void OnClick() { await GameData.Auth.SignInAnonymouslyAsync().ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInAnonymouslyAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception); return; } user = task.Result; Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId); }); var name = TopManager.UI.Name.text; if (name == null) { name = "no name"; } var profile = new Firebase.Auth.UserProfile { DisplayName = name }; //var user = GameData.Auth.CurrentUser; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } Debug.Log("User profile updated successfully."); }); TopManager.Created = true; }
void UpdateFBUser() { Firebase.Auth.FirebaseUser user = auth.CurrentUser; Firebase.Auth.UserProfile test; string imageURL = profile.picture.data.url; /* * user.UpdateEmailAsync (profile.email).ContinueWith(task => { * if (task.IsCanceled) { * Debug.LogError("UpdateUserProfileAsync was canceled."); * return; * } * if (task.IsFaulted) { * Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); * return; * } * }); * */ if (user != null) { Firebase.Auth.UserProfile _profile = new Firebase.Auth.UserProfile { DisplayName = user.DisplayName, // Email = user.Email, PhotoUrl = new System.Uri(imageURL), }; user.UpdateUserProfileAsync(_profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("UpdateUserProfileAsync encountered an error: " + task.Exception); return; } SaveFBUSerData(); OpenMainPage(); Debug.Log("User profile updated successfully."); }); } }
public IEnumerator PushUserToFirebase() { firebaseManager.enableLoadingScreen(); Firebase.Auth.FirebaseUser newUser = null; bool done = false; string errorMessage = ""; publicUserData = new PublicUserData(programs, inspirencEmail.text, school.text, memberName.text, "Member", Int32.Parse(grade.text)); privateUserData = new PrivateUserData(personalEmail.text, address.text, parent1name.text, parent1email.text, parent1number.text, parent2name.text, parent2email.text, parent2number.text, phoneNumber.text, getCheckedGender(), Int32.Parse(age.text)); firebaseManager.auth.CreateUserWithEmailAndPasswordAsync(publicUserData.inspirencEmail, passwordInput.text.ToString()).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { errorMessage = errorMessage = (task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19, task.Exception.ToString().Substring(task.Exception.ToString().IndexOf("FirebaseException: ") + 19).IndexOf(".") + 1));; done = true; return; } else if (task.IsCompleted) { newUser = task.Result; done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; if (errorMessage.Equals("The email address is already in use by another account.")) { firebaseManager.setErrorMessage("The email address is already in use by another account."); yield return(new WaitForSeconds(4)); reset(); yield break; } Firebase.Auth.FirebaseUser user = firebaseManager.auth.CurrentUser; if (user != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = publicUserData.name }; user.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } done = true; }); } yield return(new WaitUntil(() => done == true)); done = false; Firebase.Auth.FirebaseUser currentUser = firebaseManager.auth.CurrentUser; currentUser.SendEmailVerificationAsync().ContinueWith(task => { done = true; }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Public Data").Child(publicUserData.name).Child(currentUser.UserId).Child("profile").SetRawJsonValueAsync(JsonUtility.ToJson(publicUserData)).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Private Data").Child(publicUserData.name).Child(currentUser.UserId).Child("profile").SetRawJsonValueAsync(JsonUtility.ToJson(privateUserData)).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Users").Child("Public Data").Child(publicUserData.name).Child(currentUser.UserId).Child("attendance").SetRawJsonValueAsync(JsonUtility.ToJson(new Attendance())).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.reference.Child("Email List").Child(inspirencEmail.text.Substring(0, inspirencEmail.text.IndexOf("@"))).SetValueAsync(inspirencEmail.text).ContinueWith(task => { if (task.IsCanceled || task.IsFaulted) { return; } if (task.IsCompleted) { done = true; } }); yield return(new WaitUntil(() => done == true)); done = false; firebaseManager.disableLoadingScreen(); }